github.com/ahmet2mir/goreleaser@v0.180.3-0.20210927151101-8e5ee5a9b8c5/cmd/check_test.go (about) 1 package cmd 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 ) 8 9 func TestCheckConfig(t *testing.T) { 10 cmd := newCheckCmd() 11 cmd.cmd.SetArgs([]string{"-f", "testdata/good.yml"}) 12 require.NoError(t, cmd.cmd.Execute()) 13 } 14 15 func TestCheckConfigThatDoesNotExist(t *testing.T) { 16 cmd := newCheckCmd() 17 cmd.cmd.SetArgs([]string{"-f", "testdata/nope.yml"}) 18 require.EqualError(t, cmd.cmd.Execute(), "open testdata/nope.yml: no such file or directory") 19 } 20 21 func TestCheckConfigUnmarshalError(t *testing.T) { 22 cmd := newCheckCmd() 23 cmd.cmd.SetArgs([]string{"-f", "testdata/unmarshal_error.yml"}) 24 require.EqualError(t, cmd.cmd.Execute(), "yaml: unmarshal errors:\n line 1: field foo not found in type config.Project") 25 } 26 27 func TestCheckConfigInvalid(t *testing.T) { 28 cmd := newCheckCmd() 29 cmd.cmd.SetArgs([]string{"-f", "testdata/invalid.yml"}) 30 require.EqualError(t, cmd.cmd.Execute(), "invalid config: found 2 builds with the ID 'a', please fix your config") 31 } 32 33 func TestCheckConfigInvalidQuiet(t *testing.T) { 34 cmd := newCheckCmd() 35 cmd.cmd.SetArgs([]string{"-f", "testdata/invalid.yml", "-q"}) 36 require.Error(t, cmd.cmd.Execute()) 37 } 38 39 func TestCheckConfigDeprecated(t *testing.T) { 40 cmd := newCheckCmd() 41 cmd.cmd.SetArgs([]string{"-f", "testdata/good.yml", "--deprecated"}) 42 require.EqualError(t, cmd.cmd.Execute(), "config is valid, but uses deprecated properties, check logs above for details") 43 }