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

Function TestChatDebugSQLGuards

coderd/database/querier_test.go:13595–13722  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13593}
13594
13595func TestChatDebugSQLGuards(t *testing.T) {
13596 t.Parallel()
13597
13598 store, _ := dbtestutil.NewDB(t)
13599 ctx := testutil.Context(t, testutil.WaitMedium)
13600
13601 org := dbgen.Organization(t, store, database.Organization{})
13602 user := dbgen.User(t, store, database.User{})
13603
13604 providerName := "openai"
13605 modelName := "debug-model-guards-" + uuid.NewString()
13606
13607 dbgen.ChatProvider(t, store, database.ChatProvider{
13608 Provider: providerName,
13609 DisplayName: "Debug Provider",
13610 APIKey: "test-key",
13611 Enabled: true,
13612 CentralApiKeyEnabled: true,
13613 })
13614
13615 modelCfg, err := insertChatModelConfigForTest(ctx, t, store, database.InsertChatModelConfigParams{
13616 Provider: providerName,
13617 Model: modelName,
13618 DisplayName: "Debug Model",
13619 CreatedBy: uuid.NullUUID{UUID: user.ID, Valid: true},
13620 UpdatedBy: uuid.NullUUID{UUID: user.ID, Valid: true},
13621 Enabled: true,
13622 IsDefault: true,
13623 ContextLimit: 128000,
13624 CompressionThreshold: 80,
13625 Options: json.RawMessage(`{}`),
13626 })
13627 require.NoError(t, err)
13628
13629 chatA, err := store.InsertChat(ctx, database.InsertChatParams{
13630 OrganizationID: org.ID,
13631 Status: database.ChatStatusWaiting,
13632 ClientType: database.ChatClientTypeUi,
13633 OwnerID: user.ID,
13634 LastModelConfigID: modelCfg.ID,
13635 Title: "chat-guard-A-" + uuid.NewString(),
13636 })
13637 require.NoError(t, err)
13638
13639 chatB, err := store.InsertChat(ctx, database.InsertChatParams{
13640 OrganizationID: org.ID,
13641 Status: database.ChatStatusWaiting,
13642 ClientType: database.ChatClientTypeUi,
13643 OwnerID: user.ID,
13644 LastModelConfigID: modelCfg.ID,
13645 Title: "chat-guard-B-" + uuid.NewString(),
13646 })
13647 require.NoError(t, err)
13648
13649 runA, err := store.InsertChatDebugRun(ctx, database.InsertChatDebugRunParams{
13650 ChatID: chatA.ID,
13651 ModelConfigID: uuid.NullUUID{UUID: modelCfg.ID, Valid: true},
13652 TriggerMessageID: sql.NullInt64{Int64: 1, Valid: true},

Callers

nothing calls this directly

Calls 12

NewDBFunction · 0.92
ContextFunction · 0.92
OrganizationFunction · 0.92
UserFunction · 0.92
ChatProviderFunction · 0.92
InsertChatMethod · 0.65
InsertChatDebugRunMethod · 0.65
InsertChatDebugStepMethod · 0.65
RunMethod · 0.65
UpdateChatDebugRunMethod · 0.65
UpdateChatDebugStepMethod · 0.65

Tested by

no test coverage detected