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.

30 lines
875 B

  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. "code.gitea.io/gitea/models"
  7. "fmt"
  8. "github.com/stretchr/testify/assert"
  9. "net/http"
  10. "testing"
  11. )
  12. func TestUserHeatmap(t *testing.T) {
  13. prepareTestEnv(t)
  14. adminUsername := "user1"
  15. normalUsername := "user2"
  16. session := loginUser(t, adminUsername)
  17. urlStr := fmt.Sprintf("/api/v1/users/%s/heatmap", normalUsername)
  18. req := NewRequest(t, "GET", urlStr)
  19. resp := session.MakeRequest(t, req, http.StatusOK)
  20. var heatmap []*models.UserHeatmapData
  21. DecodeJSON(t, resp, &heatmap)
  22. var dummyheatmap []*models.UserHeatmapData
  23. dummyheatmap = append(dummyheatmap, &models.UserHeatmapData{Timestamp: 1540080000, Contributions: 1})
  24. assert.Equal(t, dummyheatmap, heatmap)
  25. }