(t *testing.T)
| 1137 | } |
| 1138 | |
| 1139 | func TestRefreshChat_UpsertError(t *testing.T) { |
| 1140 | t.Parallel() |
| 1141 | ctx := testutil.Context(t, testutil.WaitShort) |
| 1142 | |
| 1143 | chatID := uuid.New() |
| 1144 | ownerID := uuid.New() |
| 1145 | |
| 1146 | row := database.ChatDiffStatus{ |
| 1147 | ChatID: chatID, |
| 1148 | GitBranch: "feature", |
| 1149 | GitRemoteOrigin: "https://github.com/owner/repo", |
| 1150 | } |
| 1151 | |
| 1152 | ctrl := gomock.NewController(t) |
| 1153 | store := dbmock.NewMockStore(ctrl) |
| 1154 | |
| 1155 | store.EXPECT().UpsertChatDiffStatus(gomock.Any(), gomock.Any()). |
| 1156 | Return(database.ChatDiffStatus{}, fmt.Errorf("db write error")) |
| 1157 | |
| 1158 | var publishCalled atomic.Bool |
| 1159 | pub := func(_ context.Context, _ uuid.UUID) error { |
| 1160 | publishCalled.Store(true) |
| 1161 | return nil |
| 1162 | } |
| 1163 | |
| 1164 | mClock := quartz.NewMock(t) |
| 1165 | logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}) |
| 1166 | refresher := newTestRefresher(t, mClock) |
| 1167 | worker := gitsync.NewWorker(store, refresher, pub, mClock, logger) |
| 1168 | |
| 1169 | result, err := worker.RefreshChat(ctx, row, ownerID) |
| 1170 | require.Error(t, err) |
| 1171 | assert.Contains(t, err.Error(), "upsert chat diff status") |
| 1172 | assert.Nil(t, result) |
| 1173 | assert.False(t, publishCalled.Load(), "publish should not be called when upsert fails") |
| 1174 | } |
| 1175 | |
| 1176 | func TestWorker_NoTokenBackoff(t *testing.T) { |
| 1177 | t.Parallel() |
nothing calls this directly
no test coverage detected