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

Function TestArchiveChatMovesPendingChatToWaiting

coderd/x/chatd/chatd_test.go:1546–1585  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1544}
1545
1546func TestArchiveChatMovesPendingChatToWaiting(t *testing.T) {
1547 t.Parallel()
1548
1549 db, ps := dbtestutil.NewDB(t)
1550 replica := newTestServer(t, db, ps, uuid.New())
1551
1552 ctx := testutil.Context(t, testutil.WaitLong)
1553 user, org, model := seedChatDependencies(t, db)
1554
1555 chat, err := replica.CreateChat(ctx, chatd.CreateOptions{
1556 OwnerID: user.ID,
1557 OrganizationID: org.ID,
1558 Title: "archive-pending",
1559 ModelConfigID: model.ID,
1560 InitialUserContent: []codersdk.ChatMessagePart{codersdk.ChatMessageText("hello")},
1561 })
1562 require.NoError(t, err)
1563
1564 chat, err = db.UpdateChatStatus(ctx, database.UpdateChatStatusParams{
1565 ID: chat.ID,
1566 Status: database.ChatStatusPending,
1567 WorkerID: uuid.NullUUID{},
1568 StartedAt: sql.NullTime{},
1569 HeartbeatAt: sql.NullTime{},
1570 LastError: pqtype.NullRawMessage{},
1571 })
1572 require.NoError(t, err)
1573
1574 err = replica.ArchiveChat(ctx, chat)
1575 require.NoError(t, err)
1576
1577 fromDB, err := db.GetChatByID(ctx, chat.ID)
1578 require.NoError(t, err)
1579 require.Equal(t, database.ChatStatusWaiting, fromDB.Status)
1580 require.False(t, fromDB.WorkerID.Valid)
1581 require.False(t, fromDB.StartedAt.Valid)
1582 require.False(t, fromDB.HeartbeatAt.Valid)
1583 require.True(t, fromDB.Archived)
1584 require.Zero(t, fromDB.PinOrder)
1585}
1586
1587// TestUnarchiveChildChat covers the deterministic branches of the
1588// Server.UnarchiveChat child path: happy path, archived-parent reject,

Callers

nothing calls this directly

Calls 11

NewDBFunction · 0.92
ContextFunction · 0.92
ChatMessageTextFunction · 0.92
ArchiveChatMethod · 0.80
newTestServerFunction · 0.70
seedChatDependenciesFunction · 0.70
NewMethod · 0.65
CreateChatMethod · 0.65
UpdateChatStatusMethod · 0.65
GetChatByIDMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected