mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	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 ;)
This commit is contained in:
		@@ -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) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user