expose route metadata and remove stale route docs
This commit is contained in:
1 parent
8e9f0d52fd
commit
b2266d7e9d
3 files changed
+43
-3
No files matched your search
+32
@@ -40,6 +40,38 @@ class GatewayDeploymentTest {
|
||||
verify(redis, atLeastOnce()).execute(any(RedisScript.class), eq(List.of("moyi:test:gateway:slots:key:" + keyId)), any(Object[].class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void modelsKeepRouteIdAndExposeDisplayMetadata() {
|
||||
CatalogService catalog = mock(CatalogService.class);
|
||||
GatewayGuard guard = mock(GatewayGuard.class);
|
||||
Map<String, Object> key = Map.of("id", UUID.randomUUID().toString());
|
||||
Map<String, Object> route = Map.of(
|
||||
"id", "route-1",
|
||||
"providerId", "provider-apihub",
|
||||
"modelKey", "deepseek-v4-flash",
|
||||
"publicName", "DeepSeek V4 Flash",
|
||||
"vendorName", "DeepSeek",
|
||||
"sourceLabel", "ApiHub 国内",
|
||||
"upstreamModel", "deepseek-v4-flash",
|
||||
"type", "text",
|
||||
"mode", "sync"
|
||||
);
|
||||
when(catalog.authenticateKey("test-key")).thenReturn(key);
|
||||
when(catalog.listModels(false)).thenReturn(List.of(route));
|
||||
when(catalog.keyCanInvoke(key, "route-1")).thenReturn(true);
|
||||
GatewayController controller = new GatewayController(catalog, mock(OpenAiCompatibleProvider.class), guard, mock(ChatBillingService.class), new ObjectMapper());
|
||||
|
||||
Map<String, Object> response = controller.models("Bearer test-key");
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> item = ((List<Map<String, Object>>) response.get("data")).getFirst();
|
||||
assertEquals("route-1", item.get("id"));
|
||||
assertEquals("deepseek-v4-flash", item.get("model_key"));
|
||||
assertEquals("DeepSeek V4 Flash", item.get("public_name"));
|
||||
assertEquals("DeepSeek", item.get("vendor_name"));
|
||||
assertEquals("ApiHub 国内", item.get("source_label"));
|
||||
assertEquals("deepseek-v4-flash", item.get("upstream_model"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void invalidRedisPrefixIsRejected() {
|
||||
assertThrows(IllegalArgumentException.class, () -> new GatewayGuard(mock(StringRedisTemplate.class), 60, 300, 4, ""));
|
||||
|
||||
Reference in new issue
Block a user