(t *testing.T)
| 2951 | } |
| 2952 | |
| 2953 | func TestUserChatProviderConfigs(t *testing.T) { |
| 2954 | t.Parallel() |
| 2955 | t.Skip("legacy chat provider API removed in favor of AI provider API") |
| 2956 | |
| 2957 | requireUserProviderConfig := func(t *testing.T, configs []codersdk.UserChatProviderConfig, provider string) codersdk.UserChatProviderConfig { |
| 2958 | t.Helper() |
| 2959 | |
| 2960 | for _, config := range configs { |
| 2961 | if config.Provider == provider { |
| 2962 | return config |
| 2963 | } |
| 2964 | } |
| 2965 | |
| 2966 | t.Fatalf("provider %q not found", provider) |
| 2967 | return codersdk.UserChatProviderConfig{} |
| 2968 | } |
| 2969 | |
| 2970 | requireNoUserProviderConfig := func(t *testing.T, configs []codersdk.UserChatProviderConfig, provider string) { |
| 2971 | t.Helper() |
| 2972 | |
| 2973 | for _, config := range configs { |
| 2974 | if config.Provider == provider { |
| 2975 | t.Fatalf("provider %q unexpectedly found", provider) |
| 2976 | } |
| 2977 | } |
| 2978 | } |
| 2979 | |
| 2980 | t.Run("ListOnlyUserKeyProviders", func(t *testing.T) { |
| 2981 | t.Parallel() |
| 2982 | |
| 2983 | ctx := testutil.Context(t, testutil.WaitLong) |
| 2984 | client := newChatClient(t) |
| 2985 | _ = coderdtest.CreateFirstUser(t, client.Client) |
| 2986 | |
| 2987 | anthropicProvider, err := client.CreateChatProvider(ctx, codersdk.CreateChatProviderConfigRequest{ |
| 2988 | Provider: "anthropic", |
| 2989 | CentralAPIKeyEnabled: ptr.Ref(false), |
| 2990 | AllowUserAPIKey: ptr.Ref(true), |
| 2991 | }) |
| 2992 | require.NoError(t, err) |
| 2993 | |
| 2994 | _, err = client.CreateChatProvider(ctx, codersdk.CreateChatProviderConfigRequest{ |
| 2995 | Provider: "google", |
| 2996 | APIKey: "central-api-key", |
| 2997 | }) |
| 2998 | require.NoError(t, err) |
| 2999 | |
| 3000 | configs, err := client.ListUserChatProviderConfigs(ctx) |
| 3001 | require.NoError(t, err) |
| 3002 | require.Len(t, configs, 1) |
| 3003 | require.Equal(t, anthropicProvider.ID, configs[0].ProviderID) |
| 3004 | require.Equal(t, anthropicProvider.Provider, configs[0].Provider) |
| 3005 | }) |
| 3006 | |
| 3007 | t.Run("ListReportsHasUserAPIKeyFalse", func(t *testing.T) { |
| 3008 | t.Parallel() |
| 3009 | |
| 3010 | ctx := testutil.Context(t, testutil.WaitLong) |
nothing calls this directly
no test coverage detected