mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-10 03:47:03 +02:00
ec2db4a727
<!-- Hi, thanks for contributing! Please make sure you read our CONTRIBUTING guide. Also, add tests and the respective documentation changes as well. --> <!-- If applied, this commit will... --> ... <!-- Why is this change being made? --> ... <!-- # Provide links to any relevant tickets, URLs or other resources --> ... --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package cmd
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/goreleaser/goreleaser/v2/pkg/config"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestConfigFlagNotSetButExists(t *testing.T) {
|
|
for _, name := range []string{
|
|
".config/goreleaser.yml",
|
|
".config/goreleaser.yaml",
|
|
".goreleaser.yml",
|
|
".goreleaser.yaml",
|
|
"goreleaser.yml",
|
|
"goreleaser.yaml",
|
|
} {
|
|
t.Run(name, func(t *testing.T) {
|
|
folder := setup(t)
|
|
require.NoError(t, os.MkdirAll(filepath.Dir(name), 0o755))
|
|
require.NoError(t, os.Rename(
|
|
filepath.Join(folder, "goreleaser.yml"),
|
|
filepath.Join(folder, name),
|
|
))
|
|
proj, err := loadConfig("")
|
|
require.NoError(t, err)
|
|
require.NotEqual(t, config.Project{}, proj)
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestConfigFileDoesntExist(t *testing.T) {
|
|
folder := setup(t)
|
|
err := os.Remove(filepath.Join(folder, "goreleaser.yml"))
|
|
require.NoError(t, err)
|
|
proj, err := loadConfig("")
|
|
require.NoError(t, err)
|
|
require.Equal(t, config.Project{}, proj)
|
|
}
|
|
|
|
func TestConfigFileFromStdin(t *testing.T) {
|
|
folder := setup(t)
|
|
err := os.Remove(filepath.Join(folder, "goreleaser.yml"))
|
|
require.NoError(t, err)
|
|
proj, err := loadConfig("-")
|
|
require.NoError(t, err)
|
|
require.Equal(t, config.Project{}, proj)
|
|
}
|