@@ -44,6 +44,7 @@ func TestDBSearchIssues(t *testing.T) {
4444 t .Run ("search issues with order" , searchIssueWithOrder )
4545 t .Run ("search issues in project" , searchIssueInProject )
4646 t .Run ("search issues with paginator" , searchIssueWithPaginator )
47+ t .Run ("search issues with any assignee" , searchIssueWithAnyAssignee )
4748}
4849
4950func searchIssueWithKeyword (t * testing.T ) {
@@ -176,19 +177,19 @@ func searchIssueByID(t *testing.T) {
176177 }{
177178 {
178179 opts : SearchOptions {
179- PosterID : optional . Some ( int64 ( 1 )) ,
180+ PosterID : "1" ,
180181 },
181182 expectedIDs : []int64 {11 , 6 , 3 , 2 , 1 },
182183 },
183184 {
184185 opts : SearchOptions {
185- AssigneeID : optional . Some ( int64 ( 1 )) ,
186+ AssigneeID : "1" ,
186187 },
187188 expectedIDs : []int64 {6 , 1 },
188189 },
189190 {
190- // NOTE: This tests no assignees filtering and also ToSearchOptions() to ensure it will set AssigneeID to 0 when it is passed as -1.
191- opts : * ToSearchOptions ("" , & issues.IssuesOptions {AssigneeID : optional . Some ( db . NoConditionID ) }),
191+ // NOTE: This tests no assignees filtering and also ToSearchOptions() to ensure it handles the filter correctly
192+ opts : * ToSearchOptions ("" , & issues.IssuesOptions {AssigneeID : "(none)" }),
192193 expectedIDs : []int64 {22 , 21 , 16 , 15 , 14 , 13 , 12 , 11 , 20 , 5 , 19 , 18 , 10 , 7 , 4 , 9 , 8 , 3 , 2 },
193194 },
194195 {
@@ -462,3 +463,25 @@ func searchIssueWithPaginator(t *testing.T) {
462463 assert .Equal (t , test .expectedTotal , total )
463464 }
464465}
466+
467+ func searchIssueWithAnyAssignee (t * testing.T ) {
468+ tests := []struct {
469+ opts SearchOptions
470+ expectedIDs []int64
471+ expectedTotal int64
472+ }{
473+ {
474+ SearchOptions {
475+ AssigneeID : "(any)" ,
476+ },
477+ []int64 {17 , 6 , 1 },
478+ 3 ,
479+ },
480+ }
481+ for _ , test := range tests {
482+ issueIDs , total , err := SearchIssues (t .Context (), & test .opts )
483+ require .NoError (t , err )
484+ assert .Equal (t , test .expectedIDs , issueIDs )
485+ assert .Equal (t , test .expectedTotal , total )
486+ }
487+ }
0 commit comments