mirror of
https://github.com/git-chglog/git-chglog.git
synced 2026-07-28 13:33:50 +00:00
test: Pass all the test cases with windows
This commit is contained in:
parent
ed6fb2722e
commit
98543fb897
2 changed files with 10 additions and 6 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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("")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue