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

Function TestRefresher_BatchGroupsByOwnerAndOrigin

coderd/x/gitsync/gitsync_test.go:431–500  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

429}
430
431func TestRefresher_BatchGroupsByOwnerAndOrigin(t *testing.T) {
432 t.Parallel()
433
434 mp := &mockProvider{
435 parsePullRequestURL: func(_ string) (gitprovider.PRRef, bool) {
436 return gitprovider.PRRef{Owner: "org", Repo: "repo", Number: 1}, true
437 },
438 fetchPullRequestStatus: func(_ context.Context, _ string, _ gitprovider.PRRef) (*gitprovider.PRStatus, error) {
439 return &gitprovider.PRStatus{State: gitprovider.PRStateOpen}, nil
440 },
441 }
442
443 providers := func(_ context.Context, _ string) gitprovider.Provider { return mp }
444
445 var tokenCalls atomic.Int32
446 tokens := func(_ context.Context, _ uuid.UUID, _ string) (*string, error) {
447 tokenCalls.Add(1)
448 return ptr.Ref("test-token"), nil
449 }
450
451 r := gitsync.NewRefresher(providers, tokens, slogtest.Make(t, nil), quartz.NewReal())
452
453 ownerID := uuid.New()
454 originA := "https://github.com/org/repo"
455 originB := "https://gitlab.com/org/repo"
456
457 requests := []gitsync.RefreshRequest{
458 {
459 Row: database.ChatDiffStatus{
460 ChatID: uuid.New(),
461 Url: sql.NullString{String: "https://github.com/org/repo/pull/1", Valid: true},
462 GitRemoteOrigin: originA,
463 GitBranch: "feature-1",
464 },
465 OwnerID: ownerID,
466 },
467 {
468 Row: database.ChatDiffStatus{
469 ChatID: uuid.New(),
470 Url: sql.NullString{String: "https://github.com/org/repo/pull/1", Valid: true},
471 GitRemoteOrigin: originA,
472 GitBranch: "feature-2",
473 },
474 OwnerID: ownerID,
475 },
476 {
477 Row: database.ChatDiffStatus{
478 ChatID: uuid.New(),
479 Url: sql.NullString{String: "https://gitlab.com/org/repo/pull/1", Valid: true},
480 GitRemoteOrigin: originB,
481 GitBranch: "feature-3",
482 },
483 OwnerID: ownerID,
484 },
485 }
486
487 results, err := r.Refresh(context.Background(), requests)
488 require.NoError(t, err)

Callers

nothing calls this directly

Calls 8

RefreshMethod · 0.95
RefFunction · 0.92
NewRefresherFunction · 0.92
AddMethod · 0.65
NewMethod · 0.65
LenMethod · 0.45
EqualMethod · 0.45
LoadMethod · 0.45

Tested by

no test coverage detected