aboutsummaryrefslogtreecommitdiffstats
path: root/models/user_heatmap_test.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2022-03-10 15:54:51 +0100
committerGitHub <noreply@github.com>2022-03-10 15:54:51 +0100
commitcc98737ca81d9552f20c277e6ad0031927f9b757 (patch)
tree5db0ddab8b4aec4586d18ee30a7586f14661be80 /models/user_heatmap_test.go
parent5fdd30423eac1f9de8546461e11d5fde26bc7d7c (diff)
downloadgitea-cc98737ca81d9552f20c277e6ad0031927f9b757.tar.gz
gitea-cc98737ca81d9552f20c277e6ad0031927f9b757.zip
RSS/Atom support for Orgs (#17714)
part of #569
Diffstat (limited to 'models/user_heatmap_test.go')
-rw-r--r--models/user_heatmap_test.go47
1 files changed, 31 insertions, 16 deletions
diff --git a/models/user_heatmap_test.go b/models/user_heatmap_test.go
index 7d2997648d..7915363d95 100644
--- a/models/user_heatmap_test.go
+++ b/models/user_heatmap_test.go
@@ -19,25 +19,40 @@ import (
func TestGetUserHeatmapDataByUser(t *testing.T) {
testCases := []struct {
+ desc string
userID int64
doerID int64
CountResult int
JSONResult string
}{
- // self looks at action in private repo
- {2, 2, 1, `[{"timestamp":1603227600,"contributions":1}]`},
- // admin looks at action in private repo
- {2, 1, 1, `[{"timestamp":1603227600,"contributions":1}]`},
- // other user looks at action in private repo
- {2, 3, 0, `[]`},
- // nobody looks at action in private repo
- {2, 0, 0, `[]`},
- // collaborator looks at action in private repo
- {16, 15, 1, `[{"timestamp":1603267200,"contributions":1}]`},
- // no action action not performed by target user
- {3, 3, 0, `[]`},
- // multiple actions performed with two grouped together
- {10, 10, 3, `[{"timestamp":1603009800,"contributions":1},{"timestamp":1603010700,"contributions":2}]`},
+ {
+ "self looks at action in private repo",
+ 2, 2, 1, `[{"timestamp":1603227600,"contributions":1}]`,
+ },
+ {
+ "admin looks at action in private repo",
+ 2, 1, 1, `[{"timestamp":1603227600,"contributions":1}]`,
+ },
+ {
+ "other user looks at action in private repo",
+ 2, 3, 0, `[]`,
+ },
+ {
+ "nobody looks at action in private repo",
+ 2, 0, 0, `[]`,
+ },
+ {
+ "collaborator looks at action in private repo",
+ 16, 15, 1, `[{"timestamp":1603267200,"contributions":1}]`,
+ },
+ {
+ "no action action not performed by target user",
+ 3, 3, 0, `[]`,
+ },
+ {
+ "multiple actions performed with two grouped together",
+ 10, 10, 3, `[{"timestamp":1603009800,"contributions":1},{"timestamp":1603010700,"contributions":2}]`,
+ },
}
// Prepare
assert.NoError(t, unittest.PrepareTestDatabase())
@@ -46,7 +61,7 @@ func TestGetUserHeatmapDataByUser(t *testing.T) {
timeutil.Set(time.Date(2021, 1, 1, 0, 0, 0, 0, time.UTC))
defer timeutil.Unset()
- for i, tc := range testCases {
+ for _, tc := range testCases {
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: tc.userID}).(*user_model.User)
doer := &user_model.User{ID: tc.doerID}
@@ -74,7 +89,7 @@ func TestGetUserHeatmapDataByUser(t *testing.T) {
}
assert.NoError(t, err)
assert.Len(t, actions, contributions, "invalid action count: did the test data became too old?")
- assert.Equal(t, tc.CountResult, contributions, fmt.Sprintf("testcase %d", i))
+ assert.Equal(t, tc.CountResult, contributions, fmt.Sprintf("testcase '%s'", tc.desc))
// Test JSON rendering
jsonData, err := json.Marshal(heatmap)