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

Function AIProviderKey

coderd/database/dbgen/dbgen.go:228–249  ·  view source on GitHub ↗
(t testing.TB, db database.Store, seed database.AIProviderKey, munge ...func(*database.InsertAIProviderKeyParams))

Source from the content-addressed store, hash-verified

226}
227
228func AIProviderKey(t testing.TB, db database.Store, seed database.AIProviderKey, munge ...func(*database.InsertAIProviderKeyParams)) database.AIProviderKey {
229 t.Helper()
230 id := seed.ID
231 if id == uuid.Nil {
232 id = uuid.New()
233 }
234 now := dbtime.Now()
235 params := database.InsertAIProviderKeyParams{
236 ID: id,
237 ProviderID: seed.ProviderID,
238 APIKey: takeFirst(seed.APIKey, "test-key"),
239 ApiKeyKeyID: seed.ApiKeyKeyID,
240 CreatedAt: takeFirst(seed.CreatedAt, now),
241 UpdatedAt: takeFirst(seed.UpdatedAt, now),
242 }
243 for _, fn := range munge {
244 fn(&params)
245 }
246 key, err := db.InsertAIProviderKey(genCtx, params)
247 require.NoError(t, err, "insert ai provider key")
248 return key
249}
250
251// AIProviderWithOptionalKey inserts an AI provider and, when apiKey is not
252// empty, inserts a provider-scoped key for it.

Callers 9

seedChatDependenciesFunction · 0.92
genDataFunction · 0.92
TestAIProviderKeysFunction · 0.92
ChatProviderFunction · 0.70

Calls 5

NowFunction · 0.92
takeFirstFunction · 0.70
HelperMethod · 0.65
NewMethod · 0.65
InsertAIProviderKeyMethod · 0.65

Tested by 7

seedChatDependenciesFunction · 0.74
genDataFunction · 0.74
TestAIProviderKeysFunction · 0.74