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

Function TestFallthrough

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

Source from the content-addressed store, hash-verified

917}
918
919func TestFallthrough(t *testing.T) {
920 t.Parallel()
921
922 testCases := []struct {
923 name string
924 fixture []byte
925 basePath string
926 requestPath string
927 expectedUpstreamPath string
928 expectAuthHeader string
929 }{
930 {
931 name: "ant_empty_base_url_path",
932 fixture: fixtures.AntFallthrough,
933 basePath: "",
934 requestPath: "/anthropic/v1/models",
935 expectedUpstreamPath: "/v1/models",
936 expectAuthHeader: "X-Api-Key",
937 },
938 {
939 name: "oai_empty_base_url_path",
940 fixture: fixtures.OaiChatFallthrough,
941 basePath: "",
942 requestPath: "/openai/v1/models",
943 expectedUpstreamPath: "/models",
944 expectAuthHeader: "Authorization",
945 },
946 {
947 name: "ant_some_base_url_path",
948 fixture: fixtures.AntFallthrough,
949 basePath: "/api",
950 requestPath: "/anthropic/v1/models",
951 expectedUpstreamPath: "/api/v1/models",
952 expectAuthHeader: "X-Api-Key",
953 },
954 {
955 name: "oai_some_base_url_path",
956 fixture: fixtures.OaiChatFallthrough,
957 basePath: "/api",
958 requestPath: "/openai/v1/models",
959 expectedUpstreamPath: "/api/models",
960 expectAuthHeader: "Authorization",
961 },
962 }
963
964 for _, tc := range testCases {
965 t.Run(tc.name, func(t *testing.T) {
966 t.Parallel()
967
968 fix := fixtures.Parse(t, tc.fixture)
969 upstream := newMockUpstream(t.Context(), t, newFixtureResponse(fix))
970 bridgeServer := newBridgeTestServer(t.Context(), t, upstream.URL+tc.basePath)
971
972 resp, err := bridgeServer.makeRequest(t, http.MethodGet, tc.requestPath, nil)
973 require.NoError(t, err)
974 defer resp.Body.Close()
975
976 require.Equal(t, http.StatusOK, resp.StatusCode)

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected