From 96562bcc9af4bebc55159acddf9768212198d13a Mon Sep 17 00:00:00 2001 From: tsuyoshiwada Date: Sat, 24 Feb 2018 00:35:19 +0900 Subject: [PATCH] test: Fix test which failed due to timezone difference --- chglog_test.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/chglog_test.go b/chglog_test.go index 586460ac..ad2be0b2 100644 --- a/chglog_test.go +++ b/chglog_test.go @@ -6,6 +6,7 @@ import ( "path/filepath" "strings" "testing" + "time" "github.com/stretchr/testify/assert" gitcmd "github.com/tsuyoshiwada/go-gitcmd" @@ -30,6 +31,9 @@ func setup(dir string, setupRepo func(gitcmd.Client)) { os.MkdirAll(testDir, os.ModePerm) os.Chdir(testDir) + loc, _ := time.LoadLocation("UTC") + time.Local = loc + git := gitcmd.New(nil) git.Exec("init") git.Exec("config", "user.name", "test_user") @@ -102,23 +106,23 @@ func TestGeneratorWithTypeScopeSubject(t *testing.T) { testName := "type_scope_subject" setup(testName, func(git gitcmd.Client) { - git.Exec("commit", "--allow-empty", "--date", "Mon Jan 1 00:00:00 2018 +0900", "-m", "chore(*): First commit") - git.Exec("commit", "--allow-empty", "--date", "Mon Jan 1 00:01:00 2018 +0900", "-m", "feat(core): Add foo bar") - git.Exec("commit", "--allow-empty", "--date", "Mon Jan 1 00:02:00 2018 +0900", "-m", "docs(readme): Update usage #123") + git.Exec("commit", "--allow-empty", "--date", "Mon Jan 1 00:00:00 2018 +0000", "-m", "chore(*): First commit") + git.Exec("commit", "--allow-empty", "--date", "Mon Jan 1 00:01:00 2018 +0000", "-m", "feat(core): Add foo bar") + git.Exec("commit", "--allow-empty", "--date", "Mon Jan 1 00:02:00 2018 +0000", "-m", "docs(readme): Update usage #123") git.Exec("tag", "1.0.0") - git.Exec("commit", "--allow-empty", "--date", "Tue Jan 2 00:00:00 2018 +0900", "-m", "feat(parser): New some super options #333") - git.Exec("commit", "--allow-empty", "--date", "Tue Jan 2 00:01:00 2018 +0900", "-m", "Merge pull request #999 from tsuyoshiwada/patch-1") - git.Exec("commit", "--allow-empty", "--date", "Tue Jan 2 00:02:00 2018 +0900", "-m", "Merge pull request #1000 from tsuyoshiwada/patch-1") - git.Exec("commit", "--allow-empty", "--date", "Tue Jan 2 00:03:00 2018 +0900", "-m", "Revert \"feat(core): Add foo bar @mention and issue #987\"") + git.Exec("commit", "--allow-empty", "--date", "Tue Jan 2 00:00:00 2018 +0000", "-m", "feat(parser): New some super options #333") + git.Exec("commit", "--allow-empty", "--date", "Tue Jan 2 00:01:00 2018 +0000", "-m", "Merge pull request #999 from tsuyoshiwada/patch-1") + git.Exec("commit", "--allow-empty", "--date", "Tue Jan 2 00:02:00 2018 +0000", "-m", "Merge pull request #1000 from tsuyoshiwada/patch-1") + git.Exec("commit", "--allow-empty", "--date", "Tue Jan 2 00:03:00 2018 +0000", "-m", "Revert \"feat(core): Add foo bar @mention and issue #987\"") git.Exec("tag", "1.1.0") - git.Exec("commit", "--allow-empty", "--date", "Wed Jan 3 00:00:00 2018 +0900", "-m", "feat(context): Online breaking change\n\nBREAKING CHANGE: Online breaking change message.") - git.Exec("commit", "--allow-empty", "--date", "Wed Jan 3 00:01:00 2018 +0900", "-m", "feat(router): Muliple breaking change\n\nThis is body,\n\nBREAKING CHANGE:\nMultiple\nbreaking\nchange message.") + git.Exec("commit", "--allow-empty", "--date", "Wed Jan 3 00:00:00 2018 +0000", "-m", "feat(context): Online breaking change\n\nBREAKING CHANGE: Online breaking change message.") + git.Exec("commit", "--allow-empty", "--date", "Wed Jan 3 00:01:00 2018 +0000", "-m", "feat(router): Muliple breaking change\n\nThis is body,\n\nBREAKING CHANGE:\nMultiple\nbreaking\nchange message.") git.Exec("tag", "2.0.0-beta.0") - git.Exec("commit", "--allow-empty", "--date", "Thu Jan 4 00:00:00 2018 +0900", "-m", "refactor(context): gofmt") - git.Exec("commit", "--allow-empty", "--date", "Thu Jan 4 00:01:00 2018 +0900", "-m", "fix(core): Fix commit\n\nThis is body message.") + git.Exec("commit", "--allow-empty", "--date", "Thu Jan 4 00:00:00 2018 +0000", "-m", "refactor(context): gofmt") + git.Exec("commit", "--allow-empty", "--date", "Thu Jan 4 00:01:00 2018 +0000", "-m", "fix(core): Fix commit\n\nThis is body message.") }) gen := NewGenerator(&Config{