test: Pass all the test cases with windows

This commit is contained in:
tsuyoshiwada 2018-03-02 02:06:19 +09:00
parent ed6fb2722e
commit 98543fb897
2 changed files with 10 additions and 6 deletions

View file

@ -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)
}

View file

@ -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("")