@@ -19,12 +19,20 @@ func TestGetUserHeatmapDataByUser(t *testing.T) {
1919 CountResult int
2020 JSONResult string
2121 }{
22- {2 , 2 , 1 , `[{"timestamp":1603152000,"contributions":1}]` }, // self looks at action in private repo
23- {2 , 1 , 1 , `[{"timestamp":1603152000,"contributions":1}]` }, // admin looks at action in private repo
24- {2 , 3 , 0 , `[]` }, // other user looks at action in private repo
25- {2 , 0 , 0 , `[]` }, // nobody looks at action in private repo
26- {16 , 15 , 1 , `[{"timestamp":1603238400,"contributions":1}]` }, // collaborator looks at action in private repo
27- {3 , 3 , 0 , `[]` }, // no action action not performed by target user
22+ // self looks at action in private repo
23+ {2 , 2 , 1 , `[{"timestamp":1603227600,"contributions":1}]` },
24+ // admin looks at action in private repo
25+ {2 , 1 , 1 , `[{"timestamp":1603227600,"contributions":1}]` },
26+ // other user looks at action in private repo
27+ {2 , 3 , 0 , `[]` },
28+ // nobody looks at action in private repo
29+ {2 , 0 , 0 , `[]` },
30+ // collaborator looks at action in private repo
31+ {16 , 15 , 1 , `[{"timestamp":1603267200,"contributions":1}]` },
32+ // no action action not performed by target user
33+ {3 , 3 , 0 , `[]` },
34+ // multiple actions performed with two grouped together
35+ {10 , 10 , 3 , `[{"timestamp":1603009800,"contributions":1},{"timestamp":1603010700,"contributions":2}]` },
2836 }
2937 // Prepare
3038 assert .NoError (t , PrepareTestDatabase ())
@@ -51,9 +59,13 @@ func TestGetUserHeatmapDataByUser(t *testing.T) {
5159
5260 // Get the heatmap and compare
5361 heatmap , err := GetUserHeatmapDataByUser (user , doer )
62+ var contributions int
63+ for _ , hm := range heatmap {
64+ contributions += int (hm .Contributions )
65+ }
5466 assert .NoError (t , err )
55- assert .Len (t , heatmap , len ( actions ) , "invalid action count: did the test data became too old?" )
56- assert .Len (t , heatmap , tc .CountResult , fmt .Sprintf ("testcase %d" , i ))
67+ assert .Len (t , actions , contributions , "invalid action count: did the test data became too old?" )
68+ assert .Equal (t , tc .CountResult , contributions , fmt .Sprintf ("testcase %d" , i ))
5769
5870 // Test JSON rendering
5971 json := jsoniter .ConfigCompatibleWithStandardLibrary
0 commit comments