github.com/fredbi/git-chglog@v0.0.0-20190706071416-d35c598eac81/cmd/git-chglog/config_test.go (about) 1 package main 2 3 import ( 4 "os" 5 "path/filepath" 6 "testing" 7 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestConfigNormalize(t *testing.T) { 12 assert := assert.New(t) 13 14 // basic 15 config := &Config{ 16 Info: Info{ 17 RepositoryURL: "https://example.com/foo/bar/", 18 }, 19 } 20 21 err := config.Normalize(&CLIContext{ 22 ConfigPath: filepath.FromSlash("/test/config.yml"), 23 }) 24 25 assert.Nil(err) 26 assert.Equal("git", config.Bin) 27 assert.Equal("https://example.com/foo/bar", config.Info.RepositoryURL) 28 assert.Equal("/test/CHANGELOG.tpl.md", filepath.ToSlash(config.Template)) 29 30 // abs template 31 cwd, _ := os.Getwd() 32 33 config = &Config{ 34 Template: filepath.Join(cwd, "CHANGELOG.tpl.md"), 35 } 36 37 err = config.Normalize(&CLIContext{ 38 ConfigPath: filepath.Join(cwd, "test", "config.yml"), 39 }) 40 41 assert.Nil(err) 42 assert.Equal(filepath.Join(cwd, "CHANGELOG.tpl.md"), config.Template) 43 }