Skip to content

Commit 3ad1064

Browse files
committed
Fix more tests
1 parent 80f7760 commit 3ad1064

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

tests/integration/api_repo_file_create_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ func TestAPICreateFile(t *testing.T) {
173173
expectedFileResponse := getExpectedFileResponseForCreate("user2/repo1", commitID, treePath, latestCommit.ID.String(), latestCommit.Committer.When)
174174
var fileResponse api.FileResponse
175175
DecodeJSON(t, resp, &fileResponse)
176+
177+
// FIXME: This is a workaround to compare time.Time values. This maybe a bug of Golang,
178+
// assume your local timezone is UTC, but a location with zero offset is not equal to UTC but they should be.
179+
expectedFileResponse.Content.LastCommitWhen, _ = time.Parse(time.RFC3339, expectedFileResponse.Content.LastCommitWhen.Format(time.RFC3339))
180+
176181
assert.EqualValues(t, expectedFileResponse.Content, fileResponse.Content)
177182
assert.EqualValues(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
178183
assert.EqualValues(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
@@ -290,6 +295,11 @@ func TestAPICreateFile(t *testing.T) {
290295
latestCommit, _ := gitRepo.GetCommitByPath(treePath)
291296
expectedFileResponse := getExpectedFileResponseForCreate("user2/empty-repo", commitID, treePath, latestCommit.ID.String(), latestCommit.Committer.When)
292297
DecodeJSON(t, resp, &fileResponse)
298+
299+
// FIXME: This is a workaround to compare time.Time values. This maybe a bug of Golang,
300+
// assume your local timezone is UTC, but a location with zero offset is not equal to UTC but they should be.
301+
expectedFileResponse.Content.LastCommitWhen, _ = time.Parse(time.RFC3339, expectedFileResponse.Content.LastCommitWhen.Format(time.RFC3339))
302+
293303
assert.EqualValues(t, expectedFileResponse.Content, fileResponse.Content)
294304
assert.EqualValues(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
295305
assert.EqualValues(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)

tests/integration/api_repo_file_update_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ func TestAPIUpdateFile(t *testing.T) {
142142
expectedFileResponse := getExpectedFileResponseForUpdate(commitID, treePath, lasCommit.ID.String(), lasCommit.Committer.When)
143143
var fileResponse api.FileResponse
144144
DecodeJSON(t, resp, &fileResponse)
145+
146+
// FIXME: This is a workaround to compare time.Time values. This maybe a bug of Golang,
147+
// assume your local timezone is UTC, but a location with zero offset is not equal to UTC but they should be.
148+
expectedFileResponse.Content.LastCommitWhen, _ = time.Parse(time.RFC3339, expectedFileResponse.Content.LastCommitWhen.Format(time.RFC3339))
149+
145150
assert.EqualValues(t, expectedFileResponse.Content, fileResponse.Content)
146151
assert.EqualValues(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
147152
assert.EqualValues(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)

0 commit comments

Comments
 (0)