mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-19 20:57:53 +02:00
duplicated code
This commit is contained in:
parent
eba57ca357
commit
c993a5baf0
@ -13,6 +13,7 @@ script:
|
|||||||
--enable=staticcheck \
|
--enable=staticcheck \
|
||||||
--enable=gofmt \
|
--enable=gofmt \
|
||||||
--enable=goimports \
|
--enable=goimports \
|
||||||
|
--enable=dupl \
|
||||||
./...
|
./...
|
||||||
after_success:
|
after_success:
|
||||||
test ! -z "$TRAVIS_TAG" && go run main.go
|
test ! -z "$TRAVIS_TAG" && go run main.go
|
||||||
|
@ -29,73 +29,23 @@ func TestFillFilesMissingFiles(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFillFilesUSENMarkdown(t *testing.T) {
|
func TestFillFilesUSENMarkdown(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assertFiles(t, "./.test/1", []string{"LICENSE.md", "README.md"})
|
||||||
|
|
||||||
cwd, _ := os.Getwd()
|
|
||||||
os.Chdir("./.test/1")
|
|
||||||
defer os.Chdir(cwd)
|
|
||||||
|
|
||||||
config := ProjectConfig{}
|
|
||||||
err := config.fillFiles()
|
|
||||||
|
|
||||||
assert.NoError(err)
|
|
||||||
assert.Equal([]string{"LICENSE.md", "README.md"}, config.Files)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFillFilesRealENMarkdown(t *testing.T) {
|
func TestFillFilesRealENMarkdown(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assertFiles(t, "./.test/2", []string{"LICENCE.md", "README.md"})
|
||||||
|
|
||||||
cwd, _ := os.Getwd()
|
|
||||||
os.Chdir("./.test/2")
|
|
||||||
defer os.Chdir(cwd)
|
|
||||||
|
|
||||||
config := ProjectConfig{}
|
|
||||||
err := config.fillFiles()
|
|
||||||
|
|
||||||
assert.NoError(err)
|
|
||||||
assert.Equal([]string{"LICENCE.md", "README.md"}, config.Files)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFillFilesArbitratryENTXT(t *testing.T) {
|
func TestFillFilesArbitratryENTXT(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assertFiles(t, "./.test/3", []string{"LICENCE.txt", "README.txt"})
|
||||||
|
|
||||||
cwd, _ := os.Getwd()
|
|
||||||
os.Chdir("./.test/3")
|
|
||||||
defer os.Chdir(cwd)
|
|
||||||
|
|
||||||
config := ProjectConfig{}
|
|
||||||
err := config.fillFiles()
|
|
||||||
|
|
||||||
assert.NoError(err)
|
|
||||||
assert.Equal([]string{"LICENCE.txt", "README.txt"}, config.Files)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFillFilesArbitratryENNoSuffix(t *testing.T) {
|
func TestFillFilesArbitratryENNoSuffix(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assertFiles(t, "./.test/4", []string{"LICENCE"})
|
||||||
|
|
||||||
cwd, _ := os.Getwd()
|
|
||||||
os.Chdir("./.test/4")
|
|
||||||
defer os.Chdir(cwd)
|
|
||||||
|
|
||||||
config := ProjectConfig{}
|
|
||||||
err := config.fillFiles()
|
|
||||||
|
|
||||||
assert.NoError(err)
|
|
||||||
assert.Equal([]string{"LICENCE"}, config.Files)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFillFilesChangelog(t *testing.T) {
|
func TestFillFilesChangelog(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assertFiles(t, "./.test/5", []string{"CHANGELOG", "CHANGELOG.md"})
|
||||||
|
|
||||||
cwd, _ := os.Getwd()
|
|
||||||
os.Chdir("./.test/5")
|
|
||||||
defer os.Chdir(cwd)
|
|
||||||
|
|
||||||
config := ProjectConfig{}
|
|
||||||
err := config.fillFiles()
|
|
||||||
|
|
||||||
assert.NoError(err)
|
|
||||||
assert.Equal([]string{"CHANGELOG", "CHANGELOG.md"}, config.Files)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidadeMissingBinaryName(t *testing.T) {
|
func TestValidadeMissingBinaryName(t *testing.T) {
|
||||||
@ -118,3 +68,17 @@ func TestValidadeMinimalConfig(t *testing.T) {
|
|||||||
config := ProjectConfig{BinaryName: "asd", Repo: "asd/asd"}
|
config := ProjectConfig{BinaryName: "asd", Repo: "asd/asd"}
|
||||||
assert.NoError(config.validate())
|
assert.NoError(config.validate())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func assertFiles(t *testing.T, dir string, files []string) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
cwd, _ := os.Getwd()
|
||||||
|
os.Chdir(dir)
|
||||||
|
defer os.Chdir(cwd)
|
||||||
|
|
||||||
|
config := ProjectConfig{}
|
||||||
|
err := config.fillFiles()
|
||||||
|
|
||||||
|
assert.NoError(err)
|
||||||
|
assert.Equal(files, config.Files)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user