(t *testing.T)
| 11467 | } |
| 11468 | |
| 11469 | func TestGetPRInsights(t *testing.T) { |
| 11470 | t.Parallel() |
| 11471 | if testing.Short() { |
| 11472 | t.SkipNow() |
| 11473 | } |
| 11474 | |
| 11475 | // setupChatInfra creates a fresh database with a user, chat provider, |
| 11476 | // and model config. Returns the store, user ID, model config ID, |
| 11477 | // and org ID. |
| 11478 | setupChatInfra := func(t *testing.T) (database.Store, uuid.UUID, uuid.UUID, uuid.UUID) { |
| 11479 | t.Helper() |
| 11480 | store, _ := dbtestutil.NewDB(t) |
| 11481 | ctx := context.Background() |
| 11482 | org := dbgen.Organization(t, store, database.Organization{}) |
| 11483 | user := dbgen.User(t, store, database.User{}) |
| 11484 | dbgen.OrganizationMember(t, store, database.OrganizationMember{UserID: user.ID, OrganizationID: org.ID}) |
| 11485 | |
| 11486 | dbgen.ChatProvider(t, store, database.ChatProvider{ |
| 11487 | Provider: "anthropic", |
| 11488 | DisplayName: "Anthropic", |
| 11489 | APIKey: "test-key", |
| 11490 | Enabled: true, |
| 11491 | CentralApiKeyEnabled: true, |
| 11492 | }) |
| 11493 | |
| 11494 | mc, err := insertChatModelConfigForTest(ctx, t, store, database.InsertChatModelConfigParams{ |
| 11495 | Provider: "anthropic", |
| 11496 | Model: "claude-4", |
| 11497 | DisplayName: "Claude 4", |
| 11498 | CreatedBy: uuid.NullUUID{UUID: user.ID, Valid: true}, |
| 11499 | UpdatedBy: uuid.NullUUID{UUID: user.ID, Valid: true}, |
| 11500 | Enabled: true, |
| 11501 | IsDefault: true, |
| 11502 | ContextLimit: 128000, |
| 11503 | CompressionThreshold: 80, |
| 11504 | Options: json.RawMessage(`{}`), |
| 11505 | }) |
| 11506 | require.NoError(t, err) |
| 11507 | |
| 11508 | return store, user.ID, mc.ID, org.ID |
| 11509 | } |
| 11510 | |
| 11511 | type chatParams struct { |
| 11512 | Store database.Store |
| 11513 | UserID uuid.UUID |
| 11514 | ModelConfigID uuid.UUID |
| 11515 | OrgID uuid.UUID |
| 11516 | } |
| 11517 | |
| 11518 | createChat := func(t *testing.T, p chatParams, title string) database.Chat { |
| 11519 | t.Helper() |
| 11520 | chat, err := p.Store.InsertChat(context.Background(), database.InsertChatParams{ |
| 11521 | OrganizationID: p.OrgID, |
| 11522 | Status: database.ChatStatusWaiting, |
| 11523 | ClientType: database.ChatClientTypeUi, |
| 11524 | OwnerID: p.UserID, |
| 11525 | LastModelConfigID: p.ModelConfigID, |
| 11526 | Title: title, |
nothing calls this directly
no test coverage detected