Complete pipeline preflight verification
This commit is contained in:
@@ -90,11 +90,22 @@ func TestPreflightLocalFailureStopsBeforeProvider(t *testing.T) {
|
||||
if err := json.Unmarshal(out.Bytes(), &report); err != nil || outcome.Status == 0 || report.Ready || client.calls != 0 {
|
||||
t.Fatalf("outcome=%+v report=%+v error=%v calls=%d", outcome, report, err, client.calls)
|
||||
}
|
||||
if last := report.Checks[len(report.Checks)-1]; last.ID != "input" || last.Scope.Path != input+"-missing" {
|
||||
t.Fatalf("input failure scope = %+v", last)
|
||||
}
|
||||
if !errors.Is(outcome.Cause, context.Canceled) && outcome.Cause == nil {
|
||||
t.Fatal("missing input cause")
|
||||
}
|
||||
out.Reset()
|
||||
stderr.Reset()
|
||||
missingReference := filepath.Join(t.TempDir(), "missing.txt")
|
||||
outcome = app.Execute(context.Background(), []string{"preflight", "demo", "--config", config, "--input-file", input, "--reference", "context=" + missingReference, "--format", "json"}, commandkit.Streams{Out: &out, Err: &stderr})
|
||||
report = preflightReport{}
|
||||
if err := json.Unmarshal(out.Bytes(), &report); err != nil || outcome.Status == 0 || len(report.Checks) == 0 || report.Checks[len(report.Checks)-1].Scope.Path != missingReference || client.calls != 0 {
|
||||
t.Fatalf("reference failure: outcome=%+v report=%+v err=%v calls=%d", outcome, report, err, client.calls)
|
||||
}
|
||||
out.Reset()
|
||||
stderr.Reset()
|
||||
outcome = app.Execute(context.Background(), []string{"preflight", "demo", "--config", config}, commandkit.Streams{Out: &out, Err: &stderr})
|
||||
if outcome.Status == 0 || out.Len() != 0 || client.calls != 0 {
|
||||
t.Fatalf("missing required flag: %+v %q", outcome, out.String())
|
||||
@@ -187,3 +198,28 @@ func TestPreflightCacheFailureWarnsWithoutPreventingReadiness(t *testing.T) {
|
||||
t.Fatalf("missing cache warning: %+v", report)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPreflightRetainsReferenceWarningWhenInputReadFails(t *testing.T) {
|
||||
probe := &runProbe{}
|
||||
_, config, input, _ := runFixture(t, probe)
|
||||
app, err := NewApplication("test", Options{Registries: runRegistries(t, probe), LLMClient: &readinessClient{content: `{"status":"ok"}`}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
empty := filepath.Join(t.TempDir(), "empty.txt")
|
||||
if err := os.WriteFile(empty, nil, 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var out, stderr bytes.Buffer
|
||||
outcome := app.Execute(context.Background(), []string{"preflight", "demo", "--config", config, "--input-file", input + "-missing", "--reference", "context=" + empty, "--format", "json"}, commandkit.Streams{Out: &out, Err: &stderr})
|
||||
var report preflightReport
|
||||
if err := json.Unmarshal(out.Bytes(), &report); err != nil || outcome.Status == 0 {
|
||||
t.Fatalf("outcome=%+v report=%+v err=%v", outcome, report, err)
|
||||
}
|
||||
for _, check := range report.Checks {
|
||||
if check.ID == "reference" && check.Result == "warning" && check.Code == "empty_reference" && check.Scope.Reference != "" {
|
||||
return
|
||||
}
|
||||
}
|
||||
t.Fatalf("reference warning lost: %+v", report.Checks)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user