github.com/joselitofilho/goreleaser@v0.155.1-0.20210123221854-e4891856c593/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  	var 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  	var 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  	var 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  	var 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 TestCheckConfigDeprecated(t *testing.T) {
    34  	var cmd = newCheckCmd()
    35  	cmd.cmd.SetArgs([]string{"-f", "testdata/good.yml", "--deprecated"})
    36  	require.EqualError(t, cmd.cmd.Execute(), "config is valid, but uses deprecated properties, check logs above for details")
    37  }