(t *testing.T)
| 917 | } |
| 918 | |
| 919 | func 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) |
nothing calls this directly
no test coverage detected