diff --git a/internal/usecase/runner_test.go b/internal/usecase/runner_test.go index 41a3711..580db21 100644 --- a/internal/usecase/runner_test.go +++ b/internal/usecase/runner_test.go @@ -490,6 +490,35 @@ func TestRunnerPrepareJSONSchemaBuildsStructuredOutputSpec(t *testing.T) { } } +func TestRunnerPrepareJSONSchemaSchemaLoadFailureReturnsValidationError(t *testing.T) { + def := promptDef(domain.FormatJSON, domain.ValidationJSONSchema, 0) + def.Validation.SchemaPath = "missing.schema.json" + validator := &fakeValidator{schemaErr: errors.New("schema unavailable")} + runner := NewRunner( + &fakePromptRepo{def: def}, + &fakeExecutionProfileRepo{profiles: map[string]*domain.ExecutionProfile{"exec": defaultExecutionProfile()}}, + defaultArtifactReader(), + defaultRenderer(), + &fakeLLM{forbid: true}, + validator, + ) + + _, err := runner.Prepare(context.Background(), domain.RunRequest{ + PromptID: "p", + ProfileID: "exec", + Inputs: singleInputRef(), + }) + if !errors.Is(err, ErrValidation) { + t.Fatalf("expected ErrValidation, got %v", err) + } + if validator.schemaLoads != 1 { + t.Fatalf("expected one schema load attempt, got %d", validator.schemaLoads) + } + if validator.schemaLoadPath != "missing.schema.json" { + t.Fatalf("expected schema path missing.schema.json, got %q", validator.schemaLoadPath) + } +} + func TestRunnerRunJSONSchemaSchemaLoadFailureFailsBeforeLLM(t *testing.T) { def := promptDef(domain.FormatJSON, domain.ValidationJSONSchema, 0) def.Validation.SchemaPath = "missing.schema.json"