1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-06 03:13:48 +02:00
goreleaser/cmd/check_test.go
Carlos Alexandro Becker 9bd0033c09
feat: refactor main.go to spf13/cobra (#1472)
* feat: refactor cli

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* feat: refactor cli

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* feat: refactor cli

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* feat: refactor cli

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* feat: refactor cli

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: revert

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* feat: refactor cli

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* feat: refactor cli

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* feat: refactor cli

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: lint

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: move

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2020-04-27 21:42:44 -03:00

38 lines
1.2 KiB
Go

package cmd
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestCheckConfig(t *testing.T) {
var cmd = newCheckCmd()
cmd.cmd.SetArgs([]string{"-f", "testdata/good.yml"})
require.NoError(t, cmd.cmd.Execute())
}
func TestCheckConfigThatDoesNotExist(t *testing.T) {
var cmd = newCheckCmd()
cmd.cmd.SetArgs([]string{"-f", "testdata/nope.yml"})
require.EqualError(t, cmd.cmd.Execute(), "open testdata/nope.yml: no such file or directory")
}
func TestCheckConfigUnmarshalError(t *testing.T) {
var cmd = newCheckCmd()
cmd.cmd.SetArgs([]string{"-f", "testdata/unmarshal_error.yml"})
require.EqualError(t, cmd.cmd.Execute(), "yaml: unmarshal errors:\n line 1: field foo not found in type config.Project")
}
func TestCheckConfigInvalid(t *testing.T) {
var cmd = newCheckCmd()
cmd.cmd.SetArgs([]string{"-f", "testdata/invalid.yml"})
require.EqualError(t, cmd.cmd.Execute(), "invalid config: found 2 builds with the ID 'a', please fix your config")
}
func TestCheckConfigDeprecated(t *testing.T) {
var cmd = newCheckCmd()
cmd.cmd.SetArgs([]string{"-f", "testdata/good.yml", "--deprecated"})
require.EqualError(t, cmd.cmd.Execute(), "config is valid, but uses deprecated properties, check logs above for details")
}