(t *testing.T)
| 1084 | } |
| 1085 | |
| 1086 | func TestFallthrough(t *testing.T) { |
| 1087 | t.Parallel() |
| 1088 | |
| 1089 | testCases := []struct { |
| 1090 | name string |
| 1091 | fixture []byte |
| 1092 | basePath string |
| 1093 | requestPath string |
| 1094 | expectedUpstreamPath string |
| 1095 | expectAuthHeader string |
| 1096 | }{ |
| 1097 | { |
| 1098 | name: "ant_empty_base_url_path", |
| 1099 | fixture: fixtures.AntFallthrough, |
| 1100 | basePath: "", |
| 1101 | requestPath: "/anthropic/v1/models", |
| 1102 | expectedUpstreamPath: "/v1/models", |
| 1103 | expectAuthHeader: "X-Api-Key", |
| 1104 | }, |
| 1105 | { |
| 1106 | name: "oai_empty_base_url_path", |
| 1107 | fixture: fixtures.OaiChatFallthrough, |
| 1108 | basePath: "", |
| 1109 | requestPath: "/openai/v1/models", |
| 1110 | expectedUpstreamPath: "/models", |
| 1111 | expectAuthHeader: "Authorization", |
| 1112 | }, |
| 1113 | { |
| 1114 | name: "ant_some_base_url_path", |
| 1115 | fixture: fixtures.AntFallthrough, |
| 1116 | basePath: "/api", |
| 1117 | requestPath: "/anthropic/v1/models", |
| 1118 | expectedUpstreamPath: "/api/v1/models", |
| 1119 | expectAuthHeader: "X-Api-Key", |
| 1120 | }, |
| 1121 | { |
| 1122 | name: "oai_some_base_url_path", |
| 1123 | fixture: fixtures.OaiChatFallthrough, |
| 1124 | basePath: "/api", |
| 1125 | requestPath: "/openai/v1/models", |
| 1126 | expectedUpstreamPath: "/api/models", |
| 1127 | expectAuthHeader: "Authorization", |
| 1128 | }, |
| 1129 | } |
| 1130 | |
| 1131 | for _, tc := range testCases { |
| 1132 | t.Run(tc.name, func(t *testing.T) { |
| 1133 | t.Parallel() |
| 1134 | |
| 1135 | fix := fixtures.Parse(t, tc.fixture) |
| 1136 | upstream := newMockUpstream(t.Context(), t, newFixtureResponse(fix)) |
| 1137 | bridgeServer := newBridgeTestServer(t.Context(), t, upstream.URL+tc.basePath) |
| 1138 | |
| 1139 | resp, err := bridgeServer.makeRequest(t, http.MethodGet, tc.requestPath, nil) |
| 1140 | require.NoError(t, err) |
| 1141 | defer resp.Body.Close() |
| 1142 | |
| 1143 | require.Equal(t, http.StatusOK, resp.StatusCode) |
nothing calls this directly
no test coverage detected