Reduce HTTP example test coupling

This commit is contained in:
2026-07-26 17:44:51 +00:00
parent a9e1b7435c
commit 719243e90c

View File

@@ -52,22 +52,20 @@ func TestMaintainedHTTPRunExampleMatchesRequestContract(t *testing.T) {
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)
var invalidExample map[string]json.RawMessage
if err := json.Unmarshal(body, &invalidExample); err != nil {
t.Fatalf("decode maintained HTTP request example: %v", err)
}
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)
invalidExample["unexpected"] = json.RawMessage(`true`)
invalidBody, err := json.Marshal(invalidExample)
if err != nil {
t.Fatalf("encode structurally invalid request example: %v", err)
}
invalidReq := httptest.NewRequest(http.MethodPost, "/v1/runs", bytes.NewReader(invalidBody))
invalidW := httptest.NewRecorder()
h.ServeHTTP(invalidW, invalidReq)
assertHTTPErrorCode(t, invalidW, http.StatusBadRequest, "invalid_json")
}
type handlerPromptRepo struct {