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.

api_user_heatmap_test.go 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2018 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.package models
  4. package integrations
  5. import (
  6. "fmt"
  7. "net/http"
  8. "testing"
  9. "time"
  10. "code.gitea.io/gitea/models"
  11. "code.gitea.io/gitea/modules/timeutil"
  12. "github.com/stretchr/testify/assert"
  13. )
  14. func TestUserHeatmap(t *testing.T) {
  15. defer prepareTestEnv(t)()
  16. adminUsername := "user1"
  17. normalUsername := "user2"
  18. session := loginUser(t, adminUsername)
  19. var fakeNow = time.Date(2011, 10, 20, 0, 0, 0, 0, time.Local)
  20. timeutil.Set(fakeNow)
  21. defer timeutil.Unset()
  22. urlStr := fmt.Sprintf("/api/v1/users/%s/heatmap", normalUsername)
  23. req := NewRequest(t, "GET", urlStr)
  24. resp := session.MakeRequest(t, req, http.StatusOK)
  25. var heatmap []*models.UserHeatmapData
  26. DecodeJSON(t, resp, &heatmap)
  27. var dummyheatmap []*models.UserHeatmapData
  28. dummyheatmap = append(dummyheatmap, &models.UserHeatmapData{Timestamp: 1603227600, Contributions: 1})
  29. assert.Equal(t, dummyheatmap, heatmap)
  30. }