MCPcopy Index your code
hub / github.com/coder/coder / TestBuildProviders

Function TestBuildProviders

cli/aibridged_internal_test.go:43–304  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

41}
42
43func TestBuildProviders(t *testing.T) {
44 t.Parallel()
45
46 t.Run("EmptyConfig", func(t *testing.T) {
47 t.Parallel()
48 providers, err := buildFromEnv(t, codersdk.AIBridgeConfig{})
49 require.NoError(t, err)
50 assert.Empty(t, providers)
51 })
52
53 t.Run("LegacyOnly", func(t *testing.T) {
54 t.Parallel()
55 cfg := codersdk.AIBridgeConfig{}
56 cfg.LegacyOpenAI.Key = serpent.String("sk-openai")
57 cfg.LegacyAnthropic.Key = serpent.String("sk-anthropic")
58
59 providers, err := buildFromEnv(t, cfg)
60 require.NoError(t, err)
61
62 names := providerNames(providers)
63 assert.Contains(t, names, aibridge.ProviderOpenAI)
64 assert.Contains(t, names, aibridge.ProviderAnthropic)
65 assert.Len(t, names, 2)
66 })
67
68 t.Run("IndexedOnly", func(t *testing.T) {
69 t.Parallel()
70 cfg := codersdk.AIBridgeConfig{
71 Providers: []codersdk.AIProviderConfig{
72 {
73 Type: aibridge.ProviderAnthropic,
74 Name: "anthropic-zdr",
75 Keys: []string{"sk-zdr"},
76 },
77 {
78 Type: aibridge.ProviderOpenAI,
79 Name: "openai-azure",
80 Keys: []string{"sk-azure"},
81 BaseURL: "https://azure.openai.com",
82 },
83 },
84 }
85
86 providers, err := buildFromEnv(t, cfg)
87 require.NoError(t, err)
88 require.Len(t, providers, 2)
89
90 byName := make(map[string]aibridge.Provider, len(providers))
91 for _, p := range providers {
92 byName[p.Name()] = p
93 }
94 require.Contains(t, byName, "anthropic-zdr")
95 require.Contains(t, byName, "openai-azure")
96 })
97
98 t.Run("LegacyOpenAIConflictsWithIndexed", func(t *testing.T) {
99 t.Parallel()
100 cfg := codersdk.AIBridgeConfig{

Callers

nothing calls this directly

Calls 13

buildFromEnvFunction · 0.85
providerNamesFunction · 0.85
bedrockConfigFromRowFunction · 0.85
RunMethod · 0.65
NameMethod · 0.65
TypeMethod · 0.65
BaseURLMethod · 0.65
EmptyMethod · 0.45
StringMethod · 0.45
ContainsMethod · 0.45
LenMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected