From 98543fb897a4837cf228e0b490861df27f43261a Mon Sep 17 00:00:00 2001 From: tsuyoshiwada Date: Fri, 2 Mar 2018 02:06:19 +0900 Subject: [PATCH] test: Pass all the test cases with windows --- cmd/git-chglog/config_test.go | 11 +++++++---- cmd/git-chglog/initializer_test.go | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cmd/git-chglog/config_test.go b/cmd/git-chglog/config_test.go index ab34c684..a56372f5 100644 --- a/cmd/git-chglog/config_test.go +++ b/cmd/git-chglog/config_test.go @@ -1,6 +1,7 @@ package main import ( + "os" "path/filepath" "testing" @@ -18,7 +19,7 @@ func TestConfigNormalize(t *testing.T) { } err := config.Normalize(&CLIContext{ - ConfigPath: "/test/config.yml", + ConfigPath: filepath.FromSlash("/test/config.yml"), }) assert.Nil(err) @@ -27,14 +28,16 @@ func TestConfigNormalize(t *testing.T) { assert.Equal("/test/CHANGELOG.tpl.md", filepath.ToSlash(config.Template)) // abs template + cwd, _ := os.Getwd() + config = &Config{ - Template: "/CHANGELOG.tpl.md", + Template: filepath.Join(cwd, "CHANGELOG.tpl.md"), } err = config.Normalize(&CLIContext{ - ConfigPath: "/test/config.yml", + ConfigPath: filepath.Join(cwd, "test", "config.yml"), }) assert.Nil(err) - assert.Equal("/CHANGELOG.tpl.md", filepath.ToSlash(config.Template)) + assert.Equal(filepath.Join(cwd, "CHANGELOG.tpl.md"), config.Template) } diff --git a/cmd/git-chglog/initializer_test.go b/cmd/git-chglog/initializer_test.go index fb929f19..95c2b1da 100644 --- a/cmd/git-chglog/initializer_test.go +++ b/cmd/git-chglog/initializer_test.go @@ -3,6 +3,7 @@ package main import ( "bytes" "errors" + "path/filepath" "testing" "github.com/stretchr/testify/assert" @@ -16,13 +17,13 @@ func TestInitializer(t *testing.T) { mockFs := &mockFileSystem{ ReturnMkdirP: func(path string) error { - if path == "/test/config" { + if path == filepath.FromSlash("/test/config") { return nil } return errors.New("") }, ReturnWriteFile: func(path string, content []byte) error { - if path == "/test/config/config.yml" || path == "/test/config/CHANGELOG.tpl.md" { + if path == filepath.FromSlash("/test/config/config.yml") || path == filepath.FromSlash("/test/config/CHANGELOG.tpl.md") { return nil } return errors.New("")