mirror of
https://github.com/goreleaser/goreleaser.git
synced 2024-12-27 01:33:39 +02:00
4fa8df6413
BREAKING CHANGE removed all deprecated options, config file should now have a `version: 2` bit ![Dont Matter](https://github.com/goreleaser/goreleaser/assets/245435/31ece16a-cb70-4e43-9caa-8364e73fbeb9) --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
64 lines
1.7 KiB
Go
64 lines
1.7 KiB
Go
package cmd
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCheckConfig(t *testing.T) {
|
|
cmd := newCheckCmd()
|
|
cmd.cmd.SetArgs([]string{"-f", "testdata/good.yml"})
|
|
require.NoError(t, cmd.cmd.Execute())
|
|
}
|
|
|
|
func TestCheckConfigNoArgs(t *testing.T) {
|
|
cmd := newCheckCmd()
|
|
cmd.cmd.SetArgs(nil)
|
|
require.NoError(t, cmd.cmd.Execute())
|
|
require.Equal(t, 1, cmd.checked)
|
|
}
|
|
|
|
func TestCheckConfigMultipleFiles(t *testing.T) {
|
|
cmd := newCheckCmd()
|
|
cmd.cmd.SetArgs([]string{"testdata/good.yml", "testdata/invalid.yml"})
|
|
require.Error(t, cmd.cmd.Execute())
|
|
require.Equal(t, 2, cmd.checked)
|
|
}
|
|
|
|
func TestCheckConfigThatDoesNotExist(t *testing.T) {
|
|
cmd := newCheckCmd()
|
|
cmd.cmd.SetArgs([]string{"-f", "testdata/nope.yml"})
|
|
require.ErrorIs(t, cmd.cmd.Execute(), os.ErrNotExist)
|
|
require.Equal(t, 0, cmd.checked)
|
|
}
|
|
|
|
func TestCheckConfigUnmarshalError(t *testing.T) {
|
|
cmd := newCheckCmd()
|
|
cmd.cmd.SetArgs([]string{"-f", "testdata/unmarshal_error.yml"})
|
|
require.EqualError(t, cmd.cmd.Execute(), "yaml: unmarshal errors:\n line 2: field foo not found in type config.Project")
|
|
require.Equal(t, 0, cmd.checked)
|
|
}
|
|
|
|
func TestCheckConfigInvalid(t *testing.T) {
|
|
cmd := newCheckCmd()
|
|
cmd.cmd.SetArgs([]string{"-f", "testdata/invalid.yml"})
|
|
require.Error(t, cmd.cmd.Execute())
|
|
require.Equal(t, 1, cmd.checked)
|
|
}
|
|
|
|
func TestCheckConfigInvalidQuiet(t *testing.T) {
|
|
cmd := newCheckCmd()
|
|
cmd.cmd.SetArgs([]string{"-f", "testdata/invalid.yml", "-q"})
|
|
require.Error(t, cmd.cmd.Execute())
|
|
require.Equal(t, 1, cmd.checked)
|
|
}
|
|
|
|
func TestCheckConfigDeprecated(t *testing.T) {
|
|
cmd := newCheckCmd()
|
|
cmd.cmd.SetArgs([]string{"-f", "testdata/good.yml", "--deprecated"})
|
|
require.Error(t, cmd.cmd.Execute())
|
|
require.Equal(t, 1, cmd.checked)
|
|
}
|