From f7ad8232e175e08e64862ac14c4316d0b50a6b66 Mon Sep 17 00:00:00 2001 From: Nick Guenther Date: Sun, 7 May 2023 15:52:41 -0400 Subject: [PATCH 1/2] In TestViewRepo2, convert timezones to local time This fixes up https://github.com/go-gitea/gitea/pull/10446; in that, the *expected* timezone was changed to the local timezone, but the computed timezone was left in UTC. The result was this failure, when run on a non-UTC system: Diff: --- Expected +++ Actual @@ -5,3 +5,3 @@ commitMsg: (string) (len=12) "init project", - commitTime: (string) (len=29) "Wed, 14 Jun 2017 09:54:21 EDT" + commitTime: (string) (len=29) "Wed, 14 Jun 2017 13:54:21 UTC" }, @@ -11,3 +11,3 @@ commitMsg: (string) (len=12) "init project", - commitTime: (string) (len=29) "Wed, 14 Jun 2017 09:54:21 EDT" + commitTime: (string) (len=29) "Wed, 14 Jun 2017 13:54:21 UTC" } Test: TestViewRepo2 I assume this was probably missed for the last couple months since the CI servers all run in UTC? The Format() string "Mon, 02 Jan 2006 15:04:05 UTC" was incorrect: 'UTC' isn't recognized as a variable placeholder, but was just being copied verbatim. It should use 'MST' in order to command Format() to output the attached timezone, which is what `time.RFC1123` has. --- tests/integration/repo_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/repo_test.go b/tests/integration/repo_test.go index 83cbaa1789f5c..7ace5ddab1206 100644 --- a/tests/integration/repo_test.go +++ b/tests/integration/repo_test.go @@ -78,7 +78,7 @@ func testViewRepo(t *testing.T) { // convert "2017-06-14 21:54:21 +0800" to "Wed, 14 Jun 2017 13:54:21 UTC" htmlTimeString, _ := s.Find("relative-time.time-since").Attr("datetime") htmlTime, _ := time.Parse(time.RFC3339, htmlTimeString) - f.commitTime = htmlTime.UTC().Format("Mon, 02 Jan 2006 15:04:05 UTC") + f.commitTime = htmlTime.In(time.Local).Format("Mon, 02 Jan 2006 15:04:05 MST") items = append(items, f) }) From a10a725182f9c3a81117512d3cf3199d0d7bbb09 Mon Sep 17 00:00:00 2001 From: Nick Guenther Date: Sun, 7 May 2023 16:03:33 -0400 Subject: [PATCH 2/2] Use time constant --- tests/integration/repo_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/repo_test.go b/tests/integration/repo_test.go index 7ace5ddab1206..840a43b5eb8db 100644 --- a/tests/integration/repo_test.go +++ b/tests/integration/repo_test.go @@ -78,7 +78,7 @@ func testViewRepo(t *testing.T) { // convert "2017-06-14 21:54:21 +0800" to "Wed, 14 Jun 2017 13:54:21 UTC" htmlTimeString, _ := s.Find("relative-time.time-since").Attr("datetime") htmlTime, _ := time.Parse(time.RFC3339, htmlTimeString) - f.commitTime = htmlTime.In(time.Local).Format("Mon, 02 Jan 2006 15:04:05 MST") + f.commitTime = htmlTime.In(time.Local).Format(time.RFC1123) items = append(items, f) })