Migrate facade tests to the new configuration contracts

This commit is contained in:
2026-11-21 14:36:07 +00:00
parent cf03bca753
commit bab3422e62
47 changed files with 183 additions and 155 deletions

View File

@@ -169,7 +169,7 @@ func TestRunObservationClassifiesInvalidOutputAndGenerationFailure(t *testing.T)
var events []promptkit.ExecutionEvent
request := promptkit.RunRequest{PromptID: "prompt", Observer: func(event promptkit.ExecutionEvent) { events = append(events, event) }}
if tc.validation != "" {
request.Validation = &promptkit.OutputContract{Format: promptkit.FormatText, ValidationMode: tc.validation}
request.Validation = &promptkit.OutputContractInput{Format: promptkit.FormatText, ValidationMode: tc.validation, RepairAttempts: new(0)}
}
result, err := engine.Run(context.Background(), request)
if tc.err != nil && (result != nil || !errors.Is(err, promptkit.ErrLLMGenerate)) {
@@ -223,8 +223,8 @@ func TestRunObservationIncludesCompletedUsageBeforeRepairFailure(t *testing.T) {
engine := observationEngine(t, client)
var events []promptkit.ExecutionEvent
result, err := engine.Run(context.Background(), promptkit.RunRequest{
PromptID: "prompt", Validation: &promptkit.OutputContract{Format: promptkit.FormatJSON,
ValidationMode: promptkit.ValidationJSON, RepairAttempts: 1},
PromptID: "prompt", Validation: &promptkit.OutputContractInput{Format: promptkit.FormatJSON,
ValidationMode: promptkit.ValidationJSON, RepairAttempts: new(1)},
Observer: func(event promptkit.ExecutionEvent) { events = append(events, event) },
})
if result != nil || !errors.Is(err, promptkit.ErrLLMGenerate) {
@@ -242,7 +242,7 @@ func TestRunObservationIncludesCompletedUsageBeforeRepairFailure(t *testing.T) {
func TestRunObservationValidationPreparationError(t *testing.T) {
engine := observationEngine(t, &fakeLLMClient{response: &promptkit.GenerateResponse{Content: "ok"}})
var events []promptkit.ExecutionEvent
result, err := engine.Run(context.Background(), promptkit.RunRequest{PromptID: "prompt", Validation: &promptkit.OutputContract{Format: promptkit.FormatJSON, ValidationMode: promptkit.ValidationJSONSchema, Schema: map[string]any{"type": "invalid"}}, Observer: func(event promptkit.ExecutionEvent) { events = append(events, event) }})
result, err := engine.Run(context.Background(), promptkit.RunRequest{PromptID: "prompt", Validation: &promptkit.OutputContractInput{Format: promptkit.FormatJSON, ValidationMode: promptkit.ValidationJSONSchema, Schema: map[string]any{"type": "invalid"}}, Observer: func(event promptkit.ExecutionEvent) { events = append(events, event) }})
if result != nil || !errors.Is(err, promptkit.ErrValidation) || len(events) != 2 || events[1].Failure != promptkit.ExecutionFailureValidation || events[1].Attempts != 0 {
t.Fatalf("result=%+v error=%v events=%+v", result, err, events)
}