You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
6 years ago
|
// Copyright 2018 The Gitea Authors. All rights reserved.
|
||
|
// Use of this source code is governed by a MIT-style
|
||
|
// license that can be found in the LICENSE file.package models
|
||
|
|
||
2 years ago
|
package integration
|
||
6 years ago
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"net/http"
|
||
|
"testing"
|
||
3 years ago
|
"time"
|
||
5 years ago
|
|
||
2 years ago
|
activities_model "code.gitea.io/gitea/models/activities"
|
||
3 years ago
|
"code.gitea.io/gitea/modules/timeutil"
|
||
2 years ago
|
"code.gitea.io/gitea/tests"
|
||
5 years ago
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
6 years ago
|
)
|
||
|
|
||
|
func TestUserHeatmap(t *testing.T) {
|
||
2 years ago
|
defer tests.PrepareTestEnv(t)()
|
||
6 years ago
|
adminUsername := "user1"
|
||
|
normalUsername := "user2"
|
||
3 years ago
|
token := getUserToken(t, adminUsername)
|
||
6 years ago
|
|
||
3 years ago
|
fakeNow := time.Date(2011, 10, 20, 0, 0, 0, 0, time.Local)
|
||
3 years ago
|
timeutil.Set(fakeNow)
|
||
|
defer timeutil.Unset()
|
||
|
|
||
3 years ago
|
urlStr := fmt.Sprintf("/api/v1/users/%s/heatmap?token=%s", normalUsername, token)
|
||
6 years ago
|
req := NewRequest(t, "GET", urlStr)
|
||
3 years ago
|
resp := MakeRequest(t, req, http.StatusOK)
|
||
2 years ago
|
var heatmap []*activities_model.UserHeatmapData
|
||
6 years ago
|
DecodeJSON(t, resp, &heatmap)
|
||
2 years ago
|
var dummyheatmap []*activities_model.UserHeatmapData
|
||
|
dummyheatmap = append(dummyheatmap, &activities_model.UserHeatmapData{Timestamp: 1603227600, Contributions: 1})
|
||
6 years ago
|
|
||
|
assert.Equal(t, dummyheatmap, heatmap)
|
||
|
}
|