@@ -23,7 +23,7 @@ func TestRefRepoInsert(t *testing.T) {
2323
2424 branchModel := & models.Branches {}
2525 require .NoError (t , gofakeit .Struct (branchModel ))
26- branchModel .Name = "main/ feat/aaa"
26+ branchModel .Name = "feat/abc /aaa"
2727 newBrance , err := repo .Insert (ctx , branchModel )
2828 require .NoError (t , err )
2929 require .NotEqual (t , uuid .Nil , newBrance .ID )
@@ -55,7 +55,7 @@ func TestRefRepoInsert(t *testing.T) {
5555 secModel := & models.Branches {}
5656 require .NoError (t , gofakeit .Struct (secModel ))
5757 secModel .RepositoryID = branch .RepositoryID
58- branchModel .Name = "main/ feat/bbb "
58+ branchModel .Name = "feat/bba/ccc "
5959 secRef , err := repo .Insert (ctx , secModel )
6060 require .NoError (t , err )
6161 require .NotEqual (t , uuid .Nil , secRef .ID )
@@ -70,39 +70,41 @@ func TestRefRepoInsert(t *testing.T) {
7070 require .True (t , cmp .Equal (secModel , sRef , dbTimeCmpOpt ))
7171
7272 // ExactMatch
73- list , hasMore , err := repo .List (ctx , models .NewListBranchParams ().SetRepositoryID (branch .RepositoryID ).SetName (utils .String (secModel .Name ), models .ExactMatch ).SetAmount (1 ))
73+ list1 , hasMore , err := repo .List (ctx , models .NewListBranchParams ().SetRepositoryID (branch .RepositoryID ).SetName (utils .String (secModel .Name ), models .ExactMatch ).SetAmount (1 ))
7474 require .NoError (t , err )
75- require .Len (t , list , 1 )
75+ require .Len (t , list1 , 1 )
7676 require .True (t , hasMore )
7777
7878 // PrefixMatch
79- list1 , hasMore , err := repo .List (ctx , models .NewListBranchParams ().SetRepositoryID (branch .RepositoryID ).SetName (utils .String (secModel .Name [:3 ]), models .PrefixMatch ).SetAmount (1 ))
79+ list2 , hasMore , err := repo .List (ctx , models .NewListBranchParams ().SetRepositoryID (branch .RepositoryID ).SetName (utils .String (secModel .Name [:3 ]), models .PrefixMatch ).SetAmount (1 ))
8080 require .NoError (t , err )
81- require .Len (t , list1 , 1 )
81+ require .Len (t , list2 , 1 )
8282 require .True (t , hasMore )
8383
8484 // SuffixMatch
85- list2 , hasMore , err := repo .List (ctx , models .NewListBranchParams ().SetRepositoryID (branch .RepositoryID ).SetName (utils .String (secModel .Name [3 :]), models .SuffixMatch ).SetAmount (1 ))
85+ list3 , hasMore , err := repo .List (ctx , models .NewListBranchParams ().SetRepositoryID (branch .RepositoryID ).SetName (utils .String (secModel .Name [3 :]), models .SuffixMatch ).SetAmount (1 ))
8686 require .NoError (t , err )
87- require .Len (t , list2 , 1 )
87+ require .Len (t , list3 , 1 )
8888 require .True (t , hasMore )
8989
9090 // LikeMatch
91- list3 , hasMore , err := repo .List (ctx , models .NewListBranchParams ().SetRepositoryID (branch .RepositoryID ).SetName (utils .String (secModel .Name [2 :5 ]), models .LikeMatch ).SetAmount (1 ))
91+ list4 , hasMore , err := repo .List (ctx , models .NewListBranchParams ().SetRepositoryID (branch .RepositoryID ).SetName (utils .String (secModel .Name [2 :4 ]), models .LikeMatch ).SetAmount (1 ))
9292 require .NoError (t , err )
93- require .Len (t , list3 , 1 )
93+ require .Len (t , list4 , 1 )
9494 require .True (t , hasMore )
9595
96- newList , hasMore , err := repo .List (ctx , models .NewListBranchParams ().SetRepositoryID (branch .RepositoryID ).SetAfter (utils .String (branchModel .Name )).SetAmount (1 ))
96+ // After
97+ // require.Len(t, branch.Name, 3)
98+ list5 , hasMore , err := repo .List (ctx , models .NewListBranchParams ().SetRepositoryID (branch .RepositoryID ).SetAfter (utils .String ("feat/abcd/aaa" )))
9799 require .NoError (t , err )
98- require .Len (t , newList , 1 )
99- require .True (t , hasMore )
100+ require .Len (t , list5 , 1 )
101+ require .False (t , hasMore )
100102
101103 affectedRows , err := repo .Delete (ctx , models .NewDeleteBranchParams ().SetID (list [0 ].ID ).SetRepositoryID (list [0 ].RepositoryID ).SetName (list [0 ].Name ))
102104 require .NoError (t , err )
103105 require .Equal (t , int64 (1 ), affectedRows )
104106
105- list , _ , err = repo .List (ctx , models .NewListBranchParams ().SetRepositoryID (branch .RepositoryID ))
107+ list6 , _ , err : = repo .List (ctx , models .NewListBranchParams ().SetRepositoryID (branch .RepositoryID ))
106108 require .NoError (t , err )
107- require .Len (t , list , 1 )
109+ require .Len (t , list6 , 1 )
108110}
0 commit comments