@ -42,7 +42,6 @@ func TestSearchRepositoryByName(t *testing.T) {
Page : 1 ,
Page : 1 ,
PageSize : 10 ,
PageSize : 10 ,
Private : true ,
Private : true ,
Searcher : & User { ID : 14 } ,
} )
} )
assert . NoError ( t , err )
assert . NoError ( t , err )
@ -56,7 +55,6 @@ func TestSearchRepositoryByName(t *testing.T) {
Page : 1 ,
Page : 1 ,
PageSize : 10 ,
PageSize : 10 ,
Private : true ,
Private : true ,
Searcher : & User { ID : 14 } ,
} )
} )
assert . NoError ( t , err )
assert . NoError ( t , err )
@ -82,16 +80,28 @@ func TestSearchRepositoryByName(t *testing.T) {
count : 8 } ,
count : 8 } ,
{ name : "PublicRepositoriesOfUser" ,
{ name : "PublicRepositoriesOfUser" ,
opts : & SearchRepoOptions { Page : 1 , PageSize : 10 , OwnerID : 15 } ,
opts : & SearchRepoOptions { Page : 1 , PageSize : 10 , OwnerID : 15 } ,
count : 3 } , // FIXME: Should return 2 (only directly owned repositories), now includes 1 public repository from owned organization
count : 2 } ,
{ name : "PublicRepositoriesOfUser2" ,
opts : & SearchRepoOptions { Page : 1 , PageSize : 10 , OwnerID : 18 } ,
count : 0 } ,
{ name : "PublicAndPrivateRepositoriesOfUser" ,
{ name : "PublicAndPrivateRepositoriesOfUser" ,
opts : & SearchRepoOptions { Page : 1 , PageSize : 10 , OwnerID : 15 , Private : true } ,
opts : & SearchRepoOptions { Page : 1 , PageSize : 10 , OwnerID : 15 , Private : true } ,
count : 6 } , // FIXME: Should return 4 (only directly owned repositories), now includes 2 repositories from owned organization
count : 4 } ,
{ name : "PublicAndPrivateRepositoriesOfUser2" ,
opts : & SearchRepoOptions { Page : 1 , PageSize : 10 , OwnerID : 18 , Private : true } ,
count : 0 } ,
{ name : "PublicRepositoriesOfUserIncludingCollaborative" ,
{ name : "PublicRepositoriesOfUserIncludingCollaborative" ,
opts : & SearchRepoOptions { Page : 1 , PageSize : 10 , OwnerID : 15 , Collaborate : true } ,
opts : & SearchRepoOptions { Page : 1 , PageSize : 10 , OwnerID : 15 , Collaborate : true } ,
count : 4 } ,
count : 4 } ,
{ name : "PublicRepositoriesOfUser2IncludingCollaborative" ,
opts : & SearchRepoOptions { Page : 1 , PageSize : 10 , OwnerID : 18 , Collaborate : true } ,
count : 1 } ,
{ name : "PublicAndPrivateRepositoriesOfUserIncludingCollaborative" ,
{ name : "PublicAndPrivateRepositoriesOfUserIncludingCollaborative" ,
opts : & SearchRepoOptions { Page : 1 , PageSize : 10 , OwnerID : 15 , Private : true , Collaborate : true } ,
opts : & SearchRepoOptions { Page : 1 , PageSize : 10 , OwnerID : 15 , Private : true , Collaborate : true } ,
count : 8 } ,
count : 8 } ,
{ name : "PublicAndPrivateRepositoriesOfUser2IncludingCollaborative" ,
opts : & SearchRepoOptions { Page : 1 , PageSize : 10 , OwnerID : 18 , Private : true , Collaborate : true } ,
count : 4 } ,
{ name : "PublicRepositoriesOfOrganization" ,
{ name : "PublicRepositoriesOfOrganization" ,
opts : & SearchRepoOptions { Page : 1 , PageSize : 10 , OwnerID : 17 } ,
opts : & SearchRepoOptions { Page : 1 , PageSize : 10 , OwnerID : 17 } ,
count : 1 } ,
count : 1 } ,
@ -113,6 +123,9 @@ func TestSearchRepositoryByName(t *testing.T) {
{ name : "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborativeByName" ,
{ name : "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborativeByName" ,
opts : & SearchRepoOptions { Keyword : "test" , Page : 1 , PageSize : 10 , OwnerID : 15 , Private : true , Collaborate : true , AllPublic : true } ,
opts : & SearchRepoOptions { Keyword : "test" , Page : 1 , PageSize : 10 , OwnerID : 15 , Private : true , Collaborate : true , AllPublic : true } ,
count : 10 } ,
count : 10 } ,
{ name : "AllPublic/PublicAndPrivateRepositoriesOfUser2IncludingCollaborativeByName" ,
opts : & SearchRepoOptions { Keyword : "test" , Page : 1 , PageSize : 10 , OwnerID : 18 , Private : true , Collaborate : true , AllPublic : true } ,
count : 8 } ,
{ name : "AllPublic/PublicRepositoriesOfOrganization" ,
{ name : "AllPublic/PublicRepositoriesOfOrganization" ,
opts : & SearchRepoOptions { Page : 1 , PageSize : 10 , OwnerID : 17 , AllPublic : true } ,
opts : & SearchRepoOptions { Page : 1 , PageSize : 10 , OwnerID : 17 , AllPublic : true } ,
count : 12 } ,
count : 12 } ,
@ -120,9 +133,6 @@ func TestSearchRepositoryByName(t *testing.T) {
for _ , testCase := range testCases {
for _ , testCase := range testCases {
t . Run ( testCase . name , func ( t * testing . T ) {
t . Run ( testCase . name , func ( t * testing . T ) {
if testCase . opts . OwnerID > 0 {
testCase . opts . Searcher = & User { ID : testCase . opts . OwnerID }
}
repos , count , err := SearchRepositoryByName ( testCase . opts )
repos , count , err := SearchRepositoryByName ( testCase . opts )
assert . NoError ( t , err )
assert . NoError ( t , err )
@ -143,10 +153,9 @@ func TestSearchRepositoryByName(t *testing.T) {
assert . Contains ( t , repo . Name , testCase . opts . Keyword )
assert . Contains ( t , repo . Name , testCase . opts . Keyword )
}
}
// FIXME: Can't check, need to fix current behaviour (see previous FIXME comments in test cases)
if testCase . opts . OwnerID > 0 && ! testCase . opts . Collaborate && ! testCase . opts . AllPublic {
/ * if testCase . opts . OwnerID > 0 && ! testCase . opts . Collaborate && ! AllPublic {
assert . Equal ( t , testCase . opts . OwnerID , repo . Owner . ID )
assert . Equal ( t , testCase . opts . OwnerID , repo . Owner . ID )
} * /
}
if ! testCase . opts . Private {
if ! testCase . opts . Private {
assert . False ( t , repo . IsPrivate )
assert . False ( t , repo . IsPrivate )