@@ -35,6 +35,34 @@ type upstreamResponse struct {
3535 OnRequest func (r * http.Request , body []byte )
3636}
3737
38+ // newFixtureResponse creates an upstreamResponse from a parsed fixture archive.
39+ // It reads whichever of 'streaming' and 'non-streaming' sections exist;
40+ // not every fixture has both (e.g. error fixtures may only define one).
41+ func newFixtureResponse (fix fixtures.Fixture ) upstreamResponse {
42+ var resp upstreamResponse
43+ if fix .Has (fixtures .SectionStreaming ) {
44+ resp .Streaming = fix .Streaming ()
45+ }
46+ if fix .Has (fixtures .SectionNonStreaming ) {
47+ resp .Blocking = fix .NonStreaming ()
48+ }
49+ return resp
50+ }
51+
52+ // newFixtureToolResponse creates an upstreamResponse from the tool-call fixture files.
53+ // It reads whichever of 'streaming/tool-call' and 'non-streaming/tool-call'
54+ // sections exist.
55+ func newFixtureToolResponse (fix fixtures.Fixture ) upstreamResponse {
56+ var resp upstreamResponse
57+ if fix .Has (fixtures .SectionStreamingToolCall ) {
58+ resp .Streaming = fix .StreamingToolCall ()
59+ }
60+ if fix .Has (fixtures .SectionNonStreamToolCall ) {
61+ resp .Blocking = fix .NonStreamingToolCall ()
62+ }
63+ return resp
64+ }
65+
3866// receivedRequest captures the details of a single request handled by mockUpstream.
3967type receivedRequest struct {
4068 Method string
@@ -70,34 +98,6 @@ type mockUpstream struct {
7098 responses []upstreamResponse
7199}
72100
73- // newFixtureResponse creates an upstreamResponse from a parsed fixture archive.
74- // It reads whichever of 'streaming' and 'non-streaming' sections exist;
75- // not every fixture has both (e.g. error fixtures may only define one).
76- func newFixtureResponse (fix fixtures.Fixture ) upstreamResponse {
77- var resp upstreamResponse
78- if fix .Has (fixtures .SectionStreaming ) {
79- resp .Streaming = fix .Streaming ()
80- }
81- if fix .Has (fixtures .SectionNonStreaming ) {
82- resp .Blocking = fix .NonStreaming ()
83- }
84- return resp
85- }
86-
87- // newFixtureToolResponse creates an upstreamResponse from the tool-call fixture files.
88- // It reads whichever of 'streaming/tool-call' and 'non-streaming/tool-call'
89- // sections exist.
90- func newFixtureToolResponse (fix fixtures.Fixture ) upstreamResponse {
91- var resp upstreamResponse
92- if fix .Has (fixtures .SectionStreamingToolCall ) {
93- resp .Streaming = fix .StreamingToolCall ()
94- }
95- if fix .Has (fixtures .SectionNonStreamToolCall ) {
96- resp .Blocking = fix .NonStreamingToolCall ()
97- }
98- return resp
99- }
100-
101101// receivedRequests returns a copy of all requests received so far.
102102func (ms * mockUpstream ) receivedRequests () []receivedRequest {
103103 ms .mu .Lock ()
0 commit comments