| 394 | } |
| 395 | |
| 396 | func TestRefresher_PRURLParseFailure(t *testing.T) { |
| 397 | t.Parallel() |
| 398 | |
| 399 | mp := &mockProvider{ |
| 400 | parsePullRequestURL: func(_ string) (gitprovider.PRRef, bool) { |
| 401 | return gitprovider.PRRef{}, false |
| 402 | }, |
| 403 | } |
| 404 | |
| 405 | providers := func(_ context.Context, _ string) gitprovider.Provider { return mp } |
| 406 | tokens := func(_ context.Context, _ uuid.UUID, _ string) (*string, error) { |
| 407 | return ptr.Ref("test-token"), nil |
| 408 | } |
| 409 | |
| 410 | r := gitsync.NewRefresher(providers, tokens, slogtest.Make(t, nil), quartz.NewReal()) |
| 411 | |
| 412 | row := database.ChatDiffStatus{ |
| 413 | ChatID: uuid.New(), |
| 414 | Url: sql.NullString{String: "https://github.com/org/repo/not-a-pr", Valid: true}, |
| 415 | GitRemoteOrigin: "https://github.com/org/repo", |
| 416 | GitBranch: "feature", |
| 417 | } |
| 418 | |
| 419 | ownerID := uuid.New() |
| 420 | results, err := r.Refresh(context.Background(), []gitsync.RefreshRequest{ |
| 421 | {Row: row, OwnerID: ownerID}, |
| 422 | }) |
| 423 | require.NoError(t, err) |
| 424 | require.Len(t, results, 1) |
| 425 | res := results[0] |
| 426 | |
| 427 | assert.Nil(t, res.Params) |
| 428 | require.Error(t, res.Error) |
| 429 | } |
| 430 | |
| 431 | func TestRefresher_BatchGroupsByOwnerAndOrigin(t *testing.T) { |
| 432 | t.Parallel() |