From 719243e90c9669c460fadf1608cb3c1321959c7c Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Sun, 26 Jul 2026 17:44:51 +0000 Subject: [PATCH] Reduce HTTP example test coupling --- internal/adapter/http/handler_test.go | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/internal/adapter/http/handler_test.go b/internal/adapter/http/handler_test.go index 7fa1765..d35e9bd 100644 --- a/internal/adapter/http/handler_test.go +++ b/internal/adapter/http/handler_test.go @@ -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 {