MCPcopy Create free account
hub / github.com/coder/aibridge / TestThinkingAdaptiveIsPreserved

Function TestThinkingAdaptiveIsPreserved

internal/integrationtest/bridge_test.go:1900–1936  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1898}
1899
1900func TestThinkingAdaptiveIsPreserved(t *testing.T) {
1901 t.Parallel()
1902
1903 fix := fixtures.Parse(t, fixtures.AntSimple)
1904
1905 for _, streaming := range []bool{true, false} {
1906 t.Run(fmt.Sprintf("streaming=%v", streaming), func(t *testing.T) {
1907 t.Parallel()
1908
1909 ctx, cancel := context.WithTimeout(t.Context(), testutil.WaitLong)
1910 t.Cleanup(cancel)
1911
1912 // Create a mock server that captures the request body sent upstream.
1913 upstream := newMockUpstream(ctx, t, newFixtureResponse(fix))
1914
1915 bridgeServer := newBridgeTestServer(ctx, t, upstream.URL)
1916
1917 // Inject adaptive thinking into the fixture request.
1918 reqBody, err := sjson.SetBytes(fix.Request(), "thinking", map[string]string{"type": "adaptive"})
1919 require.NoError(t, err)
1920 reqBody, err = sjson.SetBytes(reqBody, "stream", streaming)
1921 require.NoError(t, err)
1922
1923 resp, err := bridgeServer.makeRequest(t, http.MethodPost, pathAnthropicMessages, reqBody)
1924 require.NoError(t, err)
1925 defer resp.Body.Close()
1926 require.Equal(t, http.StatusOK, resp.StatusCode)
1927 _, err = io.ReadAll(resp.Body)
1928 require.NoError(t, err)
1929
1930 // Verify the thinking field was preserved in the upstream request.
1931 received := upstream.receivedRequests()
1932 require.Len(t, received, 1)
1933 assert.Equal(t, "adaptive", gjson.GetBytes(received[0].Body, "thinking.type").Str)
1934 })
1935 }
1936}
1937
1938func TestEnvironmentDoNotLeak(t *testing.T) {
1939 // NOTE: Cannot use t.Parallel() here because subtests use t.Setenv which requires sequential execution.

Callers

nothing calls this directly

Calls 8

ParseFunction · 0.92
newMockUpstreamFunction · 0.85
newFixtureResponseFunction · 0.85
newBridgeTestServerFunction · 0.85
RequestMethod · 0.80
makeRequestMethod · 0.80
receivedRequestsMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected