setChatStatus transitions a chat to the given status.
( ctx context.Context, t *testing.T, db database.Store, chatID uuid.UUID, status database.ChatStatus, lastError string, )
| 3048 | |
| 3049 | // setChatStatus transitions a chat to the given status. |
| 3050 | func setChatStatus( |
| 3051 | ctx context.Context, |
| 3052 | t *testing.T, |
| 3053 | db database.Store, |
| 3054 | chatID uuid.UUID, |
| 3055 | status database.ChatStatus, |
| 3056 | lastError string, |
| 3057 | ) { |
| 3058 | t.Helper() |
| 3059 | |
| 3060 | params := database.UpdateChatStatusParams{ |
| 3061 | ID: chatID, |
| 3062 | Status: status, |
| 3063 | } |
| 3064 | if lastError != "" { |
| 3065 | encodedLastError, err := json.Marshal(codersdk.ChatError{ |
| 3066 | Message: lastError, |
| 3067 | Kind: codersdk.ChatErrorKindGeneric, |
| 3068 | }) |
| 3069 | require.NoError(t, err) |
| 3070 | params.LastError = pqtype.NullRawMessage{RawMessage: encodedLastError, Valid: true} |
| 3071 | } |
| 3072 | _, err := db.UpdateChatStatus(ctx, params) |
| 3073 | require.NoError(t, err) |
| 3074 | } |
| 3075 | |
| 3076 | // insertAssistantMessage inserts an assistant message with v1 content |
| 3077 | // into a chat. |
no test coverage detected