WaitForChatSettled waits for a chat to leave active processing and drains tracked chat daemon work before returning the final row.
( ctx context.Context, t testing.TB, api *coderd.API, chatID uuid.UUID, )
| 86 | // WaitForChatSettled waits for a chat to leave active processing and drains |
| 87 | // tracked chat daemon work before returning the final row. |
| 88 | func WaitForChatSettled( |
| 89 | ctx context.Context, |
| 90 | t testing.TB, |
| 91 | api *coderd.API, |
| 92 | chatID uuid.UUID, |
| 93 | ) database.Chat { |
| 94 | t.Helper() |
| 95 | |
| 96 | require.NotNil(t, api) |
| 97 | waitForChatTerminalState(ctx, t, api.Database, chatID) |
| 98 | |
| 99 | server := api.ChatDaemonForTest() |
| 100 | require.NotNil(t, server) |
| 101 | chatd.WaitUntilIdleForTest(server) |
| 102 | |
| 103 | chat, err := getChatByIDAsSystem(ctx, api.Database, chatID) |
| 104 | require.NoError(t, err) |
| 105 | return chat |
| 106 | } |
| 107 | |
| 108 | func waitForChatTerminalState( |
| 109 | ctx context.Context, |