1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/config/config_test.go
Carlos Alexandro Becker 12436a5bf4
improved config
2016-12-31 10:03:25 -02:00

107 lines
2.2 KiB
Go

package config
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestFillBasicData(t *testing.T) {
assert := assert.New(t)
config := ProjectConfig{}
config.fillBasicData()
assert.Equal("main.go", config.Build.Main)
assert.Contains(config.Build.Oses, "darwin")
assert.Contains(config.Build.Oses, "linux")
assert.Contains(config.Build.Arches, "386")
assert.Contains(config.Build.Arches, "amd64")
}
func TestFillFilesMissingFiles(t *testing.T) {
assert := assert.New(t)
config := ProjectConfig{}
err := config.fillFiles()
assert.NoError(err)
assert.Equal([]string{}, config.Files)
}
func TestFillFilesUSENMarkdown(t *testing.T) {
assert := assert.New(t)
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) {
assert := assert.New(t)
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) {
assert := assert.New(t)
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) {
assert := assert.New(t)
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 TestValidadeMissingBinaryName(t *testing.T) {
assert := assert.New(t)
config := ProjectConfig{Repo: "asd/asd"}
assert.Error(config.validade())
}
func TestValidadeMissingRepo(t *testing.T) {
assert := assert.New(t)
config := ProjectConfig{BinaryName: "asd"}
assert.Error(config.validade())
}
func TestValidadeMinimalConfig(t *testing.T) {
assert := assert.New(t)
config := ProjectConfig{BinaryName: "asd", Repo: "asd/asd"}
assert.NoError(config.validade())
}