Preserve smoke observer failures independently of readiness
This commit is contained in:
@@ -111,3 +111,28 @@ func TestSmokeCaptureFailureStopsBeforeFurtherChecks(t *testing.T) {
|
||||
t.Fatalf("observations=%+v err=%v", observations, err)
|
||||
}
|
||||
}
|
||||
|
||||
type smokeResultClient struct{ err error }
|
||||
|
||||
func (client smokeResultClient) Generate(context.Context, promptkit.GenerateRequest) (*promptkit.GenerateResponse, error) {
|
||||
return &promptkit.GenerateResponse{Content: `{"status":"ok"}`}, client.err
|
||||
}
|
||||
|
||||
func TestSmokeRetainsTerminalObserverAndDiagnosticErrors(t *testing.T) {
|
||||
providerErr := errors.New("provider failed")
|
||||
observerErr := errors.New("observer failed")
|
||||
for _, cause := range []error{nil, providerErr} {
|
||||
input := configkit.Input{Destination: configkit.Keys("promptkit"), Source: configkit.Mapping("smoke", map[string]any{"profiles": []any{map[string]any{"id": "profile", "endpoint": "http://example.invalid/v1", "model": "fixture"}}})}
|
||||
engine, err := promptkit.NewEngine(promptkit.Config{Sources: promptkit.ConfigurationSources{Main: &input}}, promptkit.WithBundledOpenRouter(false), promptkit.WithLLMClient(smokeResultClient{cause}))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
observations, err := RunSmokeChecksObserved(context.Background(), engine, Targets{Profiles: []ProfileTarget{{ID: "profile"}}}, nil, nil, func(SmokeObservation) error { return observerErr })
|
||||
if len(observations) != 1 || !errors.Is(err, observerErr) || cause != nil && !errors.Is(err, observations[0].Err) {
|
||||
t.Fatalf("observations=%+v error=%v", observations, err)
|
||||
}
|
||||
if (observations[0].Err != nil) != (cause != nil) {
|
||||
t.Fatalf("recording failure changed native verdict: %+v", observations[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user