mirror of
https://github.com/git-chglog/git-chglog.git
synced 2026-01-23 02:15:12 +00:00
some fixes of tests on Windows
This commit is contained in:
parent
c284c96eae
commit
51d980ff82
2 changed files with 11 additions and 7 deletions
|
|
@ -4,6 +4,8 @@ import (
|
|||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
chglog "github.com/git-chglog/git-chglog"
|
||||
|
|
@ -66,13 +68,13 @@ func TestCLIForFile(t *testing.T) {
|
|||
|
||||
mockFS := &mockFileSystem{
|
||||
ReturnMkdirP: func(path string) error {
|
||||
if path != "/dir/to" {
|
||||
if filepath.ToSlash(path) != "/dir/to" {
|
||||
return errors.New("")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
ReturnCreate: func(name string) (File, error) {
|
||||
if name != "/dir/to/CHANGELOG.tpl" {
|
||||
if filepath.ToSlash(name) != "/dir/to/CHANGELOG.tpl" {
|
||||
return nil, errors.New("")
|
||||
}
|
||||
return &mockFile{
|
||||
|
|
@ -88,7 +90,7 @@ func TestCLIForFile(t *testing.T) {
|
|||
|
||||
configLoader := &mockConfigLoaderImpl{
|
||||
ReturnLoad: func(path string) (*Config, error) {
|
||||
if path != "/.chglog/config.yml" {
|
||||
if filepath.ToSlash(path) != "/.chglog/config.yml" {
|
||||
return nil, errors.New("")
|
||||
}
|
||||
return &Config{
|
||||
|
|
@ -99,7 +101,7 @@ func TestCLIForFile(t *testing.T) {
|
|||
|
||||
generator := &mockGeneratorImpl{
|
||||
ReturnGenerate: func(w io.Writer, query string, config *chglog.Config) error {
|
||||
if config.Bin != "/custom/bin/git" {
|
||||
if filepath.ToSlash(config.Bin) != "/custom/bin/git" {
|
||||
return errors.New("")
|
||||
}
|
||||
w.Write([]byte("success!!"))
|
||||
|
|
@ -122,5 +124,6 @@ func TestCLIForFile(t *testing.T) {
|
|||
|
||||
assert.Equal(ExitCodeOK, c.Run())
|
||||
assert.Equal("", stderr.String())
|
||||
assert.Contains(stdout.String(), "Generate of \"/dir/to/CHANGELOG.tpl\"")
|
||||
out := regexp.MustCompile("\x1b\\[[^a-z]*[a-z]").ReplaceAllString(stdout.String(), "")
|
||||
assert.Contains(out, "Generate of \"/dir/to/CHANGELOG.tpl\"")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
@ -23,7 +24,7 @@ func TestConfigNormalize(t *testing.T) {
|
|||
assert.Nil(err)
|
||||
assert.Equal("git", config.Bin)
|
||||
assert.Equal("https://example.com/foo/bar", config.Info.RepositoryURL)
|
||||
assert.Equal("/test/CHANGELOG.tpl.md", config.Template)
|
||||
assert.Equal("/test/CHANGELOG.tpl.md", filepath.ToSlash(config.Template))
|
||||
|
||||
// abs template
|
||||
config = &Config{
|
||||
|
|
@ -35,5 +36,5 @@ func TestConfigNormalize(t *testing.T) {
|
|||
})
|
||||
|
||||
assert.Nil(err)
|
||||
assert.Equal("/CHANGELOG.tpl.md", config.Template)
|
||||
assert.Equal("/CHANGELOG.tpl.md", filepath.ToSlash(config.Template))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue