1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-16 03:52:12 +02:00
goreleaser/cmd/check_test.go
Carlos Alexandro Becker 3707fe4d82
feat: allow to goreleaser check multiple files (#3980)
This will be more useful for goreleaser pro than for oss, but I thought
it might worth it having it in both versions.
2023-05-03 23:28:55 -03:00

45 lines
1.2 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 TestCheckConfigThatDoesNotExist(t *testing.T) {
cmd := newCheckCmd()
cmd.cmd.SetArgs([]string{"-f", "testdata/nope.yml"})
require.ErrorIs(t, cmd.cmd.Execute(), os.ErrNotExist)
}
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 1: field foo not found in type config.Project")
}
func TestCheckConfigInvalid(t *testing.T) {
cmd := newCheckCmd()
cmd.cmd.SetArgs([]string{"-f", "testdata/invalid.yml"})
require.Error(t, cmd.cmd.Execute())
}
func TestCheckConfigInvalidQuiet(t *testing.T) {
cmd := newCheckCmd()
cmd.cmd.SetArgs([]string{"-f", "testdata/invalid.yml", "-q"})
require.Error(t, cmd.cmd.Execute())
}
func TestCheckConfigDeprecated(t *testing.T) {
cmd := newCheckCmd()
cmd.cmd.SetArgs([]string{"-f", "testdata/good.yml", "--deprecated"})
require.Error(t, cmd.cmd.Execute())
}