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

Function TestCreateChatProvider

coderd/exp_chats_test.go:2331–2630  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2329}
2330
2331func TestCreateChatProvider(t *testing.T) {
2332 t.Parallel()
2333 t.Skip("legacy chat provider API removed in favor of AI provider API")
2334
2335 t.Run("Success", func(t *testing.T) {
2336 t.Parallel()
2337
2338 ctx := testutil.Context(t, testutil.WaitLong)
2339 client := newChatClient(t)
2340 _ = coderdtest.CreateFirstUser(t, client.Client)
2341
2342 provider, err := client.CreateChatProvider(ctx, codersdk.CreateChatProviderConfigRequest{
2343 Provider: "openai",
2344 DisplayName: "OpenAI Primary",
2345 APIKey: "test-api-key",
2346 })
2347 require.NoError(t, err)
2348 require.NotEqual(t, uuid.Nil, provider.ID)
2349 require.Equal(t, "openai", provider.Provider)
2350 require.Equal(t, "OpenAI Primary", provider.DisplayName)
2351 require.True(t, provider.Enabled)
2352 require.True(t, provider.HasAPIKey)
2353 require.Equal(t, codersdk.ChatProviderConfigSourceDatabase, provider.Source)
2354 })
2355
2356 t.Run("AllowsBedrockWithCentralAPIKeyEnabledWithoutStoredKey", func(t *testing.T) {
2357 t.Parallel()
2358
2359 ctx := testutil.Context(t, testutil.WaitLong)
2360 client := newChatClient(t)
2361 _ = coderdtest.CreateFirstUser(t, client.Client)
2362
2363 provider, err := client.CreateChatProvider(ctx, codersdk.CreateChatProviderConfigRequest{
2364 Provider: "bedrock",
2365 DisplayName: "AWS Bedrock",
2366 CentralAPIKeyEnabled: ptr.Ref(true),
2367 })
2368 require.NoError(t, err)
2369 require.NotEqual(t, uuid.Nil, provider.ID)
2370 require.Equal(t, "bedrock", provider.Provider)
2371 require.Equal(t, "AWS Bedrock", provider.DisplayName)
2372 require.True(t, provider.Enabled)
2373 require.False(t, provider.HasAPIKey)
2374 require.True(t, provider.CentralAPIKeyEnabled)
2375 require.Equal(t, codersdk.ChatProviderConfigSourceDatabase, provider.Source)
2376
2377 providers, err := client.ListChatProviders(ctx)
2378 require.NoError(t, err)
2379 for _, listed := range providers {
2380 if listed.Provider == "bedrock" {
2381 require.False(t, listed.HasAPIKey)
2382 return
2383 }
2384 }
2385 t.Fatal("bedrock provider not found")
2386 })
2387
2388 t.Run("ReportsBedrockAmbientFallbackForUserConfigs", func(t *testing.T) {

Callers

nothing calls this directly

Calls 15

CreateChatProviderMethod · 0.95
ContextFunction · 0.92
CreateFirstUserFunction · 0.92
RefFunction · 0.92
CreateAnotherUserFunction · 0.92
NewExperimentalClientFunction · 0.92
requireSDKErrorFunction · 0.85
chatDeploymentValuesFunction · 0.85
SkipMethod · 0.80
ListChatProvidersMethod · 0.80
FatalMethod · 0.80

Tested by

no test coverage detected