Reduce HTTP example test coupling
This commit is contained in:
@@ -52,22 +52,20 @@ func TestMaintainedHTTPRunExampleMatchesRequestContract(t *testing.T) {
|
|||||||
if w.Code != http.StatusOK {
|
if w.Code != http.StatusOK {
|
||||||
t.Fatalf("expected maintained HTTP request example to be accepted, got %d: %s", w.Code, w.Body.String())
|
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" {
|
invalidExample["unexpected"] = json.RawMessage(`true`)
|
||||||
t.Fatalf("unexpected profile ID: %q", runner.last.ProfileID)
|
invalidBody, err := json.Marshal(invalidExample)
|
||||||
}
|
if err != nil {
|
||||||
wantInputs := map[string]domain.ArtifactRef{
|
t.Fatalf("encode structurally invalid request example: %v", err)
|
||||||
"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)
|
|
||||||
}
|
}
|
||||||
|
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 {
|
type handlerPromptRepo struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user