Skip to content

Commit 2f444f5

Browse files
committed
fix test and comment
1 parent 330c7e2 commit 2f444f5

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

models/issues/issue_search.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ func applyAssigneeCondition(sess *xorm.Session, assigneeID string) {
369369
}
370370

371371
func applyPosterCondition(sess *xorm.Session, posterID string) {
372+
// Actually every issue has a poster.
373+
// The "(none)" is for internal usage only: when doer tries to search non-existing user as poster, use "(none)" to return empty result.
372374
if posterID == "(none)" {
373375
sess.And("issue.poster_id=0")
374376
} else if posterIDInt64, _ := strconv.ParseInt(posterID, 10, 64); posterIDInt64 > 0 {

modules/indexer/issues/internal/tests/tests.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ var cases = []*testIndexerCase{
379379
Paginator: &db.ListOptions{
380380
PageSize: 5,
381381
},
382-
PosterID: optional.Some(int64(1)),
382+
PosterID: "1",
383383
},
384384
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
385385
assert.Len(t, result.Hits, 5)
@@ -397,7 +397,7 @@ var cases = []*testIndexerCase{
397397
Paginator: &db.ListOptions{
398398
PageSize: 5,
399399
},
400-
AssigneeID: optional.Some(int64(1)),
400+
AssigneeID: "1",
401401
},
402402
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
403403
assert.Len(t, result.Hits, 5)
@@ -415,7 +415,7 @@ var cases = []*testIndexerCase{
415415
Paginator: &db.ListOptions{
416416
PageSize: 5,
417417
},
418-
AssigneeID: optional.Some(int64(0)),
418+
AssigneeID: "(none)",
419419
},
420420
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
421421
assert.Len(t, result.Hits, 5)
@@ -650,7 +650,7 @@ var cases = []*testIndexerCase{
650650
{
651651
Name: "SearchAnyAssignee",
652652
SearchOptions: &internal.SearchOptions{
653-
AnyAssigneeOnly: true,
653+
AssigneeID: "(any)",
654654
},
655655
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
656656
assert.Len(t, result.Hits, 180)

routers/web/shared/user/helper.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func GetFilterUserIDByName(ctx context.Context, name string) string {
4444
if id, err := strconv.ParseInt(name, 10, 64); err == nil {
4545
return strconv.FormatInt(id, 10)
4646
}
47+
// The "(none)" is for internal usage only: when doer tries to search non-existing user, use "(none)" to return empty result.
4748
return "(none)"
4849
}
4950
return strconv.FormatInt(u.ID, 10)

0 commit comments

Comments
 (0)