@@ -568,70 +568,91 @@ func TestRepositories_Integration(t *testing.T) {
568
568
}
569
569
ctx = actor .WithActor (ctx , actor .FromUser (admin .ID ))
570
570
571
- runRepositoriesQuery (t , ctx , schema , repositoriesQueryTest {
572
- wantRepos : []string {"repo1" , "repo2" , "repo3" , "repo4" , "repo5" , "repo6" },
573
- wantTotalCount : 6 ,
574
- })
575
-
576
- runRepositoriesQuery (t , ctx , schema , repositoriesQueryTest {
577
- // cloned only says whether to "Include cloned repositories.", it doesn't exclude non-cloned.
578
- args : "cloned: true" ,
579
- wantRepos : []string {"repo1" , "repo2" , "repo3" , "repo4" , "repo5" , "repo6" },
580
- wantTotalCount : 6 ,
581
- })
582
-
583
- runRepositoriesQuery (t , ctx , schema , repositoriesQueryTest {
584
- args : "cloned: false" ,
585
- wantRepos : []string {"repo1" , "repo2" , "repo3" , "repo4" },
586
- // Right now we don't produce a totalCount if "cloned: false" is used
587
- wantNoTotalCount : true ,
588
- })
589
-
590
- runRepositoriesQuery (t , ctx , schema , repositoriesQueryTest {
591
- args : "notCloned: true" ,
592
- wantRepos : []string {"repo1" , "repo2" , "repo3" , "repo4" , "repo5" , "repo6" },
593
- wantTotalCount : 6 ,
594
- })
595
-
596
- runRepositoriesQuery (t , ctx , schema , repositoriesQueryTest {
597
- args : "notCloned: false" ,
598
- wantRepos : []string {"repo5" , "repo6" },
599
- // Right now we don't produce a totalCount if "notCloned" is used
600
- wantNoTotalCount : true ,
601
- })
602
-
603
- runRepositoriesQuery (t , ctx , schema , repositoriesQueryTest {
604
- args : "failedFetch: true" ,
605
- wantRepos : []string {"repo2" , "repo4" , "repo6" },
606
- wantTotalCount : 3 ,
607
- })
608
-
609
- runRepositoriesQuery (t , ctx , schema , repositoriesQueryTest {
610
- args : "failedFetch: false" ,
611
- wantRepos : []string {"repo1" , "repo2" , "repo3" , "repo4" , "repo5" , "repo6" },
612
- wantTotalCount : 6 ,
613
- })
614
-
615
- runRepositoriesQuery (t , ctx , schema , repositoriesQueryTest {
616
- args : "cloneStatus:NOT_CLONED" ,
617
- wantRepos : []string {"repo1" , "repo2" },
618
- // Right now we don't produce a totalCount if "cloneStatus" is used
619
- wantNoTotalCount : true ,
620
- })
571
+ tests := []repositoriesQueryTest {
572
+ // no args
573
+ {
574
+ wantRepos : []string {"repo1" , "repo2" , "repo3" , "repo4" , "repo5" , "repo6" },
575
+ wantTotalCount : 6 ,
576
+ },
577
+ // first
578
+ {
579
+ args : "first: 2" ,
580
+ wantRepos : []string {"repo1" , "repo2" },
581
+ wantTotalCount : 6 ,
582
+ },
583
+ // cloned
584
+ {
585
+ // cloned only says whether to "Include cloned repositories.", it doesn't exclude non-cloned.
586
+ args : "cloned: true" ,
587
+ wantRepos : []string {"repo1" , "repo2" , "repo3" , "repo4" , "repo5" , "repo6" },
588
+ wantTotalCount : 6 ,
589
+ },
590
+ {
591
+ args : "cloned: false" ,
592
+ wantRepos : []string {"repo1" , "repo2" , "repo3" , "repo4" },
593
+ wantTotalCount : 4 ,
594
+ },
595
+ {
596
+ args : "cloned: false, first: 2" ,
597
+ wantRepos : []string {"repo1" , "repo2" },
598
+ wantTotalCount : 4 ,
599
+ },
600
+ // notCloned
601
+ {
602
+ args : "notCloned: true" ,
603
+ wantRepos : []string {"repo1" , "repo2" , "repo3" , "repo4" , "repo5" , "repo6" },
604
+ wantTotalCount : 6 ,
605
+ },
606
+ {
607
+ args : "notCloned: false" ,
608
+ wantRepos : []string {"repo5" , "repo6" },
609
+ wantTotalCount : 2 ,
610
+ },
611
+ // failedFetch
612
+ {
613
+ args : "failedFetch: true" ,
614
+ wantRepos : []string {"repo2" , "repo4" , "repo6" },
615
+ wantTotalCount : 3 ,
616
+ },
617
+ {
618
+ args : "failedFetch: true, first: 2" ,
619
+ wantRepos : []string {"repo2" , "repo4" },
620
+ wantTotalCount : 3 ,
621
+ },
622
+ {
623
+ args : "failedFetch: false" ,
624
+ wantRepos : []string {"repo1" , "repo2" , "repo3" , "repo4" , "repo5" , "repo6" },
625
+ wantTotalCount : 6 ,
626
+ },
627
+ // cloneStatus
628
+ {
629
+ args : "cloneStatus:NOT_CLONED" ,
630
+ wantRepos : []string {"repo1" , "repo2" },
631
+ wantTotalCount : 2 ,
632
+ },
633
+ {
634
+ args : "cloneStatus:CLONING" ,
635
+ wantRepos : []string {"repo3" , "repo4" },
636
+ wantTotalCount : 2 ,
637
+ },
638
+ {
639
+ args : "cloneStatus:CLONED" ,
640
+ wantRepos : []string {"repo5" , "repo6" },
641
+ wantTotalCount : 2 ,
642
+ },
643
+ {
644
+ args : "cloneStatus:NOT_CLONED, first: 1" ,
645
+ wantRepos : []string {"repo1" },
646
+ wantTotalCount : 2 ,
647
+ },
648
+ }
621
649
622
- runRepositoriesQuery (t , ctx , schema , repositoriesQueryTest {
623
- args : "cloneStatus:CLONING" ,
624
- wantRepos : []string {"repo3" , "repo4" },
625
- // Right now we don't produce a totalCount if "cloneStatus" is used
626
- wantNoTotalCount : true ,
627
- })
650
+ for _ , tt := range tests {
651
+ t .Run (tt .args , func (t * testing.T ) {
652
+ runRepositoriesQuery (t , ctx , schema , tt )
653
+ })
654
+ }
628
655
629
- runRepositoriesQuery (t , ctx , schema , repositoriesQueryTest {
630
- args : "cloneStatus:CLONED" ,
631
- wantRepos : []string {"repo5" , "repo6" },
632
- // Right now we don't produce a totalCount if "cloneStatus" is used
633
- wantNoTotalCount : true ,
634
- })
635
656
}
636
657
637
658
type repositoriesQueryTest struct {
0 commit comments