(t *testing.T)
| 1898 | } |
| 1899 | |
| 1900 | func 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 | |
| 1938 | func TestEnvironmentDoNotLeak(t *testing.T) { |
| 1939 | // NOTE: Cannot use t.Parallel() here because subtests use t.Setenv which requires sequential execution. |
nothing calls this directly
no test coverage detected