summaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-09-18 14:09:26 +0200
committerGitHub <noreply@github.com>2020-09-18 20:09:26 +0800
commit1418288734b430330023e4e17747175e4fea2f41 (patch)
tree270f7bdbb6aee5f732a6d1295ce3d021d3e98874 /integrations
parent5995326d51ab42014c6d77d3313233641c258318 (diff)
downloadgitea-1418288734b430330023e4e17747175e4fea2f41.tar.gz
gitea-1418288734b430330023e4e17747175e4fea2f41.zip
Refactor: move Commit To APIFormat Code & Lot of StopWatch related things (#12729)
* move GitCommit to APIFormat convertion into convert package * rename Commit convert functions * move stopwatch to api convertion into convert package & rm unused code & extend test * fix compare time * Gitea not Gogs ;)
Diffstat (limited to 'integrations')
-rw-r--r--integrations/api_issue_stopwatch_test.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/integrations/api_issue_stopwatch_test.go b/integrations/api_issue_stopwatch_test.go
index e0fe00c415..39b9b97411 100644
--- a/integrations/api_issue_stopwatch_test.go
+++ b/integrations/api_issue_stopwatch_test.go
@@ -7,6 +7,7 @@ package integrations
import (
"net/http"
"testing"
+ "time"
"code.gitea.io/gitea/models"
api "code.gitea.io/gitea/modules/structs"
@@ -26,12 +27,19 @@ func TestAPIListStopWatches(t *testing.T) {
resp := session.MakeRequest(t, req, http.StatusOK)
var apiWatches []*api.StopWatch
DecodeJSON(t, resp, &apiWatches)
- expect := models.AssertExistsAndLoadBean(t, &models.Stopwatch{UserID: owner.ID}).(*models.Stopwatch)
- expectAPI, _ := expect.APIFormat()
- assert.Len(t, apiWatches, 1)
-
- assert.EqualValues(t, expectAPI.IssueIndex, apiWatches[0].IssueIndex)
- assert.EqualValues(t, expectAPI.Created.Unix(), apiWatches[0].Created.Unix())
+ stopwatch := models.AssertExistsAndLoadBean(t, &models.Stopwatch{UserID: owner.ID}).(*models.Stopwatch)
+ issue := models.AssertExistsAndLoadBean(t, &models.Issue{ID: stopwatch.IssueID}).(*models.Issue)
+ if assert.Len(t, apiWatches, 1) {
+ assert.EqualValues(t, stopwatch.CreatedUnix.AsTime().Unix(), apiWatches[0].Created.Unix())
+ apiWatches[0].Created = time.Time{}
+ assert.EqualValues(t, api.StopWatch{
+ Created: time.Time{},
+ IssueIndex: issue.Index,
+ IssueTitle: issue.Title,
+ RepoName: repo.Name,
+ RepoOwnerName: repo.OwnerName,
+ }, *apiWatches[0])
+ }
}
func TestAPIStopStopWatches(t *testing.T) {