mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-11 19:28:33 +00:00
chore: type Provider.list() as Record<ProviderID, Info>, delete dead code (#18123)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { test, expect } from "bun:test"
|
||||
import path from "path"
|
||||
|
||||
import { ProviderID } from "../../src/provider/schema"
|
||||
import { tmpdir } from "../fixture/fixture"
|
||||
import { Instance } from "../../src/project/instance"
|
||||
import { Provider } from "../../src/provider/provider"
|
||||
@@ -25,8 +26,8 @@ test("GitLab Duo: loads provider with API key from environment", async () => {
|
||||
},
|
||||
fn: async () => {
|
||||
const providers = await Provider.list()
|
||||
expect(providers["gitlab"]).toBeDefined()
|
||||
expect(providers["gitlab"].key).toBe("test-gitlab-token")
|
||||
expect(providers[ProviderID.gitlab]).toBeDefined()
|
||||
expect(providers[ProviderID.gitlab].key).toBe("test-gitlab-token")
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -57,8 +58,8 @@ test("GitLab Duo: config instanceUrl option sets baseURL", async () => {
|
||||
},
|
||||
fn: async () => {
|
||||
const providers = await Provider.list()
|
||||
expect(providers["gitlab"]).toBeDefined()
|
||||
expect(providers["gitlab"].options?.instanceUrl).toBe("https://gitlab.example.com")
|
||||
expect(providers[ProviderID.gitlab]).toBeDefined()
|
||||
expect(providers[ProviderID.gitlab].options?.instanceUrl).toBe("https://gitlab.example.com")
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -95,7 +96,7 @@ test("GitLab Duo: loads with OAuth token from auth.json", async () => {
|
||||
},
|
||||
fn: async () => {
|
||||
const providers = await Provider.list()
|
||||
expect(providers["gitlab"]).toBeDefined()
|
||||
expect(providers[ProviderID.gitlab]).toBeDefined()
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -130,8 +131,8 @@ test("GitLab Duo: loads with Personal Access Token from auth.json", async () =>
|
||||
},
|
||||
fn: async () => {
|
||||
const providers = await Provider.list()
|
||||
expect(providers["gitlab"]).toBeDefined()
|
||||
expect(providers["gitlab"].key).toBe("glpat-test-pat-token")
|
||||
expect(providers[ProviderID.gitlab]).toBeDefined()
|
||||
expect(providers[ProviderID.gitlab].key).toBe("glpat-test-pat-token")
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -162,8 +163,8 @@ test("GitLab Duo: supports self-hosted instance configuration", async () => {
|
||||
},
|
||||
fn: async () => {
|
||||
const providers = await Provider.list()
|
||||
expect(providers["gitlab"]).toBeDefined()
|
||||
expect(providers["gitlab"].options?.instanceUrl).toBe("https://gitlab.company.internal")
|
||||
expect(providers[ProviderID.gitlab]).toBeDefined()
|
||||
expect(providers[ProviderID.gitlab].options?.instanceUrl).toBe("https://gitlab.company.internal")
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -193,7 +194,7 @@ test("GitLab Duo: config apiKey takes precedence over environment variable", asy
|
||||
},
|
||||
fn: async () => {
|
||||
const providers = await Provider.list()
|
||||
expect(providers["gitlab"]).toBeDefined()
|
||||
expect(providers[ProviderID.gitlab]).toBeDefined()
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -216,8 +217,8 @@ test("GitLab Duo: includes context-1m beta header in aiGatewayHeaders", async ()
|
||||
},
|
||||
fn: async () => {
|
||||
const providers = await Provider.list()
|
||||
expect(providers["gitlab"]).toBeDefined()
|
||||
expect(providers["gitlab"].options?.aiGatewayHeaders?.["anthropic-beta"]).toContain("context-1m-2025-08-07")
|
||||
expect(providers[ProviderID.gitlab]).toBeDefined()
|
||||
expect(providers[ProviderID.gitlab].options?.aiGatewayHeaders?.["anthropic-beta"]).toContain("context-1m-2025-08-07")
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -250,9 +251,9 @@ test("GitLab Duo: supports feature flags configuration", async () => {
|
||||
},
|
||||
fn: async () => {
|
||||
const providers = await Provider.list()
|
||||
expect(providers["gitlab"]).toBeDefined()
|
||||
expect(providers["gitlab"].options?.featureFlags).toBeDefined()
|
||||
expect(providers["gitlab"].options?.featureFlags?.duo_agent_platform_agentic_chat).toBe(true)
|
||||
expect(providers[ProviderID.gitlab]).toBeDefined()
|
||||
expect(providers[ProviderID.gitlab].options?.featureFlags).toBeDefined()
|
||||
expect(providers[ProviderID.gitlab].options?.featureFlags?.duo_agent_platform_agentic_chat).toBe(true)
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -275,8 +276,8 @@ test("GitLab Duo: has multiple agentic chat models available", async () => {
|
||||
},
|
||||
fn: async () => {
|
||||
const providers = await Provider.list()
|
||||
expect(providers["gitlab"]).toBeDefined()
|
||||
const models = Object.keys(providers["gitlab"].models)
|
||||
expect(providers[ProviderID.gitlab]).toBeDefined()
|
||||
const models = Object.keys(providers[ProviderID.gitlab].models)
|
||||
expect(models.length).toBeGreaterThan(0)
|
||||
expect(models).toContain("duo-chat-haiku-4-5")
|
||||
expect(models).toContain("duo-chat-sonnet-4-5")
|
||||
|
||||
Reference in New Issue
Block a user