Skip to content

Commit

Permalink
Merge 5c456f8 into 1554e38
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Feb 28, 2018
2 parents 1554e38 + 5c456f8 commit dc4e1a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 8 additions & 5 deletions cmd/git-chglog/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"bytes"
"errors"
"io"
"path/filepath"
"regexp"
"testing"

chglog "github.com/git-chglog/git-chglog"
Expand Down Expand Up @@ -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{
Expand All @@ -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{
Expand All @@ -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!!"))
Expand All @@ -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\"")
}
5 changes: 3 additions & 2 deletions cmd/git-chglog/config_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -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{
Expand All @@ -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))
}

0 comments on commit dc4e1a3

Please sign in to comment.