diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-12-29 21:02:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-29 21:02:12 +0800 |
commit | 8ce1b539b1aaf242903b5b0c342dd592bd8da8d9 (patch) | |
tree | 455d363b51d69a9be4058961a16d5c43b7698f47 /models/issue_test.go | |
parent | 8fa97a25f0dccc4db94d344ce7af632f8fe358b0 (diff) | |
download | gitea-8ce1b539b1aaf242903b5b0c342dd592bd8da8d9.tar.gz gitea-8ce1b539b1aaf242903b5b0c342dd592bd8da8d9.zip |
Use conditions but not repo ids as query condition (#16839)
* Use conditions but not repo ids as query condition
* Improve the performance of pulls/issue
* Remove duplicated code
* fix lint
* Fix bug
* Fix stats
* More fixes
* Fix build
* Fix lint
* Fix test
* Fix build
* Adjust the logic
* Merge
* Fix conflicts
* improve the performance
* Add comments for the query conditions functions
* Some improvements
Diffstat (limited to 'models/issue_test.go')
-rw-r--r-- | models/issue_test.go | 77 |
1 files changed, 40 insertions, 37 deletions
diff --git a/models/issue_test.go b/models/issue_test.go index eadeb66ab9..cebf20af9b 100644 --- a/models/issue_test.go +++ b/models/issue_test.go @@ -206,52 +206,52 @@ func TestGetUserIssueStats(t *testing.T) { FilterMode: FilterModeAll, }, IssueStats{ - YourRepositoriesCount: 0, - AssignCount: 1, - CreateCount: 1, - OpenCount: 0, - ClosedCount: 0, + YourRepositoriesCount: 1, // 6 + AssignCount: 1, // 6 + CreateCount: 1, // 6 + OpenCount: 1, // 6 + ClosedCount: 1, // 1 }, }, { UserIssueStatsOptions{ UserID: 1, - FilterMode: FilterModeAssign, + RepoIDs: []int64{1}, + FilterMode: FilterModeAll, + IsClosed: true, }, IssueStats{ - YourRepositoriesCount: 0, - AssignCount: 2, - CreateCount: 2, - OpenCount: 2, - ClosedCount: 0, + YourRepositoriesCount: 1, // 6 + AssignCount: 0, + CreateCount: 0, + OpenCount: 1, // 6 + ClosedCount: 1, // 1 }, }, { UserIssueStatsOptions{ UserID: 1, - FilterMode: FilterModeCreate, + FilterMode: FilterModeAssign, }, IssueStats{ - YourRepositoriesCount: 0, - AssignCount: 2, - CreateCount: 2, - OpenCount: 2, + YourRepositoriesCount: 1, // 6 + AssignCount: 1, // 6 + CreateCount: 1, // 6 + OpenCount: 1, // 6 ClosedCount: 0, }, }, { UserIssueStatsOptions{ - UserID: 2, - UserRepoIDs: []int64{1, 2}, - FilterMode: FilterModeAll, - IsClosed: true, + UserID: 1, + FilterMode: FilterModeCreate, }, IssueStats{ - YourRepositoriesCount: 2, - AssignCount: 0, - CreateCount: 2, - OpenCount: 2, - ClosedCount: 2, + YourRepositoriesCount: 1, // 6 + AssignCount: 1, // 6 + CreateCount: 1, // 6 + OpenCount: 1, // 6 + ClosedCount: 0, }, }, { @@ -260,9 +260,10 @@ func TestGetUserIssueStats(t *testing.T) { FilterMode: FilterModeMention, }, IssueStats{ - YourRepositoriesCount: 0, - AssignCount: 2, - CreateCount: 2, + YourRepositoriesCount: 1, // 6 + AssignCount: 1, // 6 + CreateCount: 1, // 6 + MentionCount: 0, OpenCount: 0, ClosedCount: 0, }, @@ -274,19 +275,21 @@ func TestGetUserIssueStats(t *testing.T) { IssueIDs: []int64{1}, }, IssueStats{ - YourRepositoriesCount: 0, - AssignCount: 1, - CreateCount: 1, - OpenCount: 1, + YourRepositoriesCount: 1, // 1 + AssignCount: 1, // 1 + CreateCount: 1, // 1 + OpenCount: 1, // 1 ClosedCount: 0, }, }, } { - stats, err := GetUserIssueStats(test.Opts) - if !assert.NoError(t, err) { - continue - } - assert.Equal(t, test.ExpectedIssueStats, *stats) + t.Run(fmt.Sprintf("%#v", test.Opts), func(t *testing.T) { + stats, err := GetUserIssueStats(test.Opts) + if !assert.NoError(t, err) { + return + } + assert.Equal(t, test.ExpectedIssueStats, *stats) + }) } } |