(t *testing.T)
| 12030 | } |
| 12031 | |
| 12032 | func TestChatPinOrderQueries(t *testing.T) { |
| 12033 | t.Parallel() |
| 12034 | if testing.Short() { |
| 12035 | t.SkipNow() |
| 12036 | } |
| 12037 | |
| 12038 | setup := func(t *testing.T) (context.Context, database.Store, uuid.UUID, uuid.UUID, uuid.UUID) { |
| 12039 | t.Helper() |
| 12040 | |
| 12041 | db, _ := dbtestutil.NewDB(t) |
| 12042 | org := dbgen.Organization(t, db, database.Organization{}) |
| 12043 | owner := dbgen.User(t, db, database.User{}) |
| 12044 | dbgen.OrganizationMember(t, db, database.OrganizationMember{UserID: owner.ID, OrganizationID: org.ID}) |
| 12045 | |
| 12046 | // Use background context for fixture setup so the |
| 12047 | // timed test context doesn't tick during DB init. |
| 12048 | bg := context.Background() |
| 12049 | dbgen.ChatProvider(t, db, database.ChatProvider{ |
| 12050 | Provider: "openai", |
| 12051 | DisplayName: "OpenAI", |
| 12052 | APIKey: "test-key", |
| 12053 | Enabled: true, |
| 12054 | CentralApiKeyEnabled: true, |
| 12055 | }) |
| 12056 | |
| 12057 | modelCfg, err := insertChatModelConfigForTest(bg, t, db, database.InsertChatModelConfigParams{ |
| 12058 | Provider: "openai", |
| 12059 | Model: "test-model", |
| 12060 | DisplayName: "Test Model", |
| 12061 | CreatedBy: uuid.NullUUID{UUID: owner.ID, Valid: true}, |
| 12062 | UpdatedBy: uuid.NullUUID{UUID: owner.ID, Valid: true}, |
| 12063 | Enabled: true, |
| 12064 | IsDefault: true, |
| 12065 | ContextLimit: 128000, |
| 12066 | CompressionThreshold: 80, |
| 12067 | Options: json.RawMessage(`{}`), |
| 12068 | }) |
| 12069 | require.NoError(t, err) |
| 12070 | |
| 12071 | ctx := testutil.Context(t, testutil.WaitMedium) |
| 12072 | return ctx, db, owner.ID, modelCfg.ID, org.ID |
| 12073 | } |
| 12074 | |
| 12075 | createChat := func(t *testing.T, ctx context.Context, db database.Store, ownerID, modelCfgID, orgID uuid.UUID, title string) database.Chat { |
| 12076 | t.Helper() |
| 12077 | |
| 12078 | chat, err := db.InsertChat(ctx, database.InsertChatParams{ |
| 12079 | OrganizationID: orgID, |
| 12080 | Status: database.ChatStatusWaiting, |
| 12081 | ClientType: database.ChatClientTypeUi, |
| 12082 | OwnerID: ownerID, |
| 12083 | LastModelConfigID: modelCfgID, |
| 12084 | Title: title, |
| 12085 | }) |
| 12086 | require.NoError(t, err) |
| 12087 | return chat |
| 12088 | } |
| 12089 |
nothing calls this directly
no test coverage detected