Normalize maintained documentation examples
This commit is contained in:
@@ -36,6 +36,40 @@ func (f *fakeRunner) Run(ctx context.Context, req domain.RunRequest) (*domain.Ru
|
||||
return f.result, nil
|
||||
}
|
||||
|
||||
func TestMaintainedHTTPRunExampleMatchesRequestContract(t *testing.T) {
|
||||
body, err := os.ReadFile(filepath.Join("..", "..", "..", "examples", "http-run.json"))
|
||||
if err != nil {
|
||||
t.Fatalf("read maintained HTTP request example: %v", err)
|
||||
}
|
||||
|
||||
runner := &fakeRunner{result: &domain.RunResult{}}
|
||||
h := NewHandler(runner)
|
||||
req := httptest.NewRequest(http.MethodPost, "/v1/runs", bytes.NewReader(body))
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
h.ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("expected maintained HTTP request example to be accepted, got %d: %s", w.Code, w.Body.String())
|
||||
}
|
||||
if runner.last.PromptID != "generic.markdown_summary" {
|
||||
t.Fatalf("unexpected prompt ID: %q", runner.last.PromptID)
|
||||
}
|
||||
if runner.last.ProfileID != "local-fast" {
|
||||
t.Fatalf("unexpected profile ID: %q", runner.last.ProfileID)
|
||||
}
|
||||
wantInputs := map[string]domain.ArtifactRef{
|
||||
"transcript": {Type: domain.ArtifactRefFile, URI: "./examples/fixtures/transcript.md"},
|
||||
"glossary": {Type: domain.ArtifactRefFile, URI: "./examples/fixtures/glossary.yml"},
|
||||
}
|
||||
if !reflect.DeepEqual(runner.last.Inputs, wantInputs) {
|
||||
t.Fatalf("unexpected inputs: got %#v, want %#v", runner.last.Inputs, wantInputs)
|
||||
}
|
||||
if runner.last.Vars["session_date"] != "2026-05-04" {
|
||||
t.Fatalf("unexpected session_date: %#v", runner.last.Vars)
|
||||
}
|
||||
}
|
||||
|
||||
type handlerPromptRepo struct {
|
||||
def *domain.PromptDefinition
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user