@@ -2,7 +2,6 @@ package iteragent_test
22
33import (
44 "context"
5- "encoding/json"
65 "fmt"
76 "net/http"
87 "net/http/httptest"
@@ -12,36 +11,6 @@ import (
1211 iteragent "github.com/GrayCodeAI/iteragent"
1312)
1413
15- // ---------------------------------------------------------------------------
16- // helpers
17- // ---------------------------------------------------------------------------
18-
19- // anthropicServer creates a test server that responds like the Anthropic API.
20- func anthropicServer (t * testing.T , handler http.HandlerFunc ) * httptest.Server {
21- t .Helper ()
22- return httptest .NewServer (handler )
23- }
24-
25- // patchAnthropicURL swaps the hardcoded Anthropic URL — we test via Complete
26- // using a mock provider that records the request body, since we cannot patch
27- // the URL directly. Instead we test NewAnthropic then swap out the http.Client
28- // by exercising exported behaviour end-to-end.
29- //
30- // The real Complete calls https://api.anthropic.com. For unit tests we instead:
31- // 1. Test Name() directly (no network)
32- // 2. Test request body construction by calling Complete against a local server
33- // via a custom http.Client set on the provider.
34- //
35- // Since anthropicProvider is unexported, we exercise Complete indirectly via
36- // an Agent backed by a mock provider that returns a fixed body. The actual
37- // HTTP layer is tested via the SSE tests and the OpenAPI adapter tests.
38- //
39- // Here we test the parts we CAN reach without reflection or unexported access:
40- // - Name() shape
41- // - thinkingBudget logic (via exported ThinkingLevel constants)
42- // - NewAnthropic constructor returns non-nil Provider
43- // - Complete on a testServer-backed provider using the internal testable path
44-
4514// ---------------------------------------------------------------------------
4615// NewAnthropic
4716// ---------------------------------------------------------------------------
@@ -80,30 +49,6 @@ func TestNewAnthropic_DifferentModels(t *testing.T) {
8049 }
8150}
8251
83- // ---------------------------------------------------------------------------
84- // Complete — via httptest (using Agent with the mock HTTP layer)
85- // ---------------------------------------------------------------------------
86-
87- // anthropicJSONResponse builds a valid Anthropic /v1/messages response body.
88- func anthropicJSONResponse (text string ) []byte {
89- resp := map [string ]interface {}{
90- "content" : []map [string ]interface {}{
91- {"type" : "text" , "text" : text },
92- },
93- }
94- b , _ := json .Marshal (resp )
95- return b
96- }
97-
98- // anthropicErrorResponse builds an Anthropic error response body.
99- func anthropicErrorResponse (msg string ) []byte {
100- resp := map [string ]interface {}{
101- "error" : map [string ]string {"message" : msg },
102- }
103- b , _ := json .Marshal (resp )
104- return b
105- }
106-
10752// TestAnthropicComplete_* tests use the Agent+Mock pattern because the
10853// anthropicProvider is unexported. The real provider path is verified via
10954// direct httptest servers in CompleteStream tests below (which use the SSEClient
0 commit comments