1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-04 03:11:55 +02:00

gometalinter fixes

This commit is contained in:
Carlos Alexandro Becker 2017-07-06 20:13:02 -03:00
parent 2e0e05134d
commit 86e46fe61d
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
5 changed files with 52 additions and 82 deletions

View File

@ -35,7 +35,7 @@ lint: ## Run all the linters
--deadline=10m \
./...
ci: lint test ## Run all the tests and code checks
ci: test lint ## Run all the tests and code checks
build: ## Build a beta version of goreleaser
go build

View File

@ -56,9 +56,11 @@ func TestConfigFlagNotSetButExists(t *testing.T) {
var assert = assert.New(t)
folder, back := setup(t)
defer back()
os.Rename(
filepath.Join(folder, "goreleaser.yml"),
filepath.Join(folder, ".goreleaser.yml"),
assert.NoError(
os.Rename(
filepath.Join(folder, "goreleaser.yml"),
filepath.Join(folder, ".goreleaser.yml"),
),
)
var flags = fakeFlags{
flags: map[string]string{},

View File

@ -88,8 +88,6 @@ func TestRunPipe(t *testing.T) {
assert := assert.New(t)
folder, err := ioutil.TempDir("", "goreleasertest")
assert.NoError(err)
_, err = os.Create(filepath.Join(folder, "bin.tar.gz"))
assert.NoError(err)
var ctx = &context.Context{
Config: config.Project{
Dist: folder,
@ -109,6 +107,11 @@ func TestRunPipe(t *testing.T) {
Publish: true,
}
client := &DummyClient{}
assert.Error(doRun(ctx, client))
assert.False(client.CreatedFile)
_, err = os.Create(filepath.Join(folder, "bin.tar.gz"))
assert.NoError(err)
assert.NoError(doRun(ctx, client))
assert.True(client.CreatedFile)
}
@ -149,33 +152,6 @@ func TestRunPipeFormatOverride(t *testing.T) {
assert.Contains(client.Content, "bin.zip")
}
func TestRunPipeArchiveDoesntExist(t *testing.T) {
assert := assert.New(t)
folder, err := ioutil.TempDir("", "goreleasertest")
assert.NoError(err)
var ctx = &context.Context{
Config: config.Project{
Dist: folder,
Archive: config.Archive{
Format: "tar.gz",
},
Brew: config.Homebrew{
GitHub: config.Repo{
Owner: "test",
Name: "test",
},
},
},
Folders: map[string]string{
"darwinamd64": "bin",
},
Publish: true,
}
client := &DummyClient{}
assert.Error(doRun(ctx, client))
assert.False(client.CreatedFile)
}
func TestRunPipeNoDarwin64Build(t *testing.T) {
assert := assert.New(t)
var ctx = &context.Context{

View File

@ -98,6 +98,7 @@ func binaryName(
target buildtarget.Target,
folder string,
) (binary string, err error) {
binary = build.Binary + ext.For(target)
if ctx.Config.Archive.Format == "binary" {
binary, err = name.ForBuild(ctx, build, target)
if err != nil {
@ -105,7 +106,6 @@ func binaryName(
}
binary = binary + ext.For(target)
}
binary = build.Binary + ext.For(target)
return filepath.Join(ctx.Config.Dist, folder, binary), nil
}

View File

@ -51,58 +51,50 @@ func TestAllBuildTargets(t *testing.T) {
}, buildTargets(build))
}
func TestValidGoosGoarchCombos(t *testing.T) {
func TestGoosGoarchCombos(t *testing.T) {
var platforms = []struct {
os, arch string
os string
arch string
valid bool
}{
{"android", "arm"},
{"darwin", "386"},
{"darwin", "amd64"},
{"dragonfly", "amd64"},
{"freebsd", "386"},
{"freebsd", "amd64"},
{"freebsd", "arm"},
{"linux", "386"},
{"linux", "amd64"},
{"linux", "arm"},
{"linux", "arm64"},
{"linux", "mips"},
{"linux", "mipsle"},
{"linux", "mips64"},
{"linux", "mips64le"},
{"linux", "ppc64"},
{"linux", "ppc64le"},
{"netbsd", "386"},
{"netbsd", "amd64"},
{"netbsd", "arm"},
{"openbsd", "386"},
{"openbsd", "amd64"},
{"openbsd", "arm"},
{"plan9", "386"},
{"plan9", "amd64"},
{"solaris", "amd64"},
{"windows", "386"},
{"windows", "amd64"},
// valid targets:
{"android", "arm", true},
{"darwin", "386", true},
{"darwin", "amd64", true},
{"dragonfly", "amd64", true},
{"freebsd", "386", true},
{"freebsd", "amd64", true},
{"freebsd", "arm", true},
{"linux", "386", true},
{"linux", "amd64", true},
{"linux", "arm", true},
{"linux", "arm64", true},
{"linux", "mips", true},
{"linux", "mipsle", true},
{"linux", "mips64", true},
{"linux", "mips64le", true},
{"linux", "ppc64", true},
{"linux", "ppc64le", true},
{"netbsd", "386", true},
{"netbsd", "amd64", true},
{"netbsd", "arm", true},
{"openbsd", "386", true},
{"openbsd", "amd64", true},
{"openbsd", "arm", true},
{"plan9", "386", true},
{"plan9", "amd64", true},
{"solaris", "amd64", true},
{"windows", "386", true},
{"windows", "amd64", true},
// invalid targets
{"darwin", "arm", false},
{"darwin", "arm64", false},
{"windows", "arm", false},
{"windows", "arm64", false},
}
for _, p := range platforms {
t.Run(fmt.Sprintf("%v %v is valid", p.os, p.arch), func(t *testing.T) {
assert.True(t, valid(buildtarget.New(p.os, p.arch, "")))
})
}
}
func TestInvalidGoosGoarchCombos(t *testing.T) {
var platforms = []struct {
os, arch string
}{
{"darwin", "arm"},
{"darwin", "arm64"},
{"windows", "arm"},
{"windows", "arm64"},
}
for _, p := range platforms {
t.Run(fmt.Sprintf("%v %v is invalid", p.os, p.arch), func(t *testing.T) {
assert.False(t, valid(buildtarget.New(p.os, p.arch, "")))
t.Run(fmt.Sprintf("%v %v valid=%v", p.os, p.arch, p.valid), func(t *testing.T) {
assert.Equal(t, p.valid, valid(buildtarget.New(p.os, p.arch, "")))
})
}
}