1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-04 03:11:55 +02:00
goreleaser/pkg/config/config_build_hook_test.go
fredbi 8d6ef40020
feat(yaml): upgraded from yaml.v2 to yaml.v3 (#3004)
* chore(yaml): upgraded from yaml.v2 to yaml.v3

* provided internal package to take care of backward
  compatible settings:
    * UnmarshalStrict method
    * mute io.EOF unmarshaling errors
    * marshal indenting with 2 chars
* adapted unit tests to new yaml v3

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>

* fixed failing tests

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
2022-03-29 14:00:53 -03:00

56 lines
1000 B
Go

package config
import (
"testing"
"github.com/goreleaser/goreleaser/internal/yaml"
"github.com/stretchr/testify/require"
)
func TestBuildHook_justString(t *testing.T) {
var actual BuildHookConfig
err := yaml.UnmarshalStrict([]byte(`pre: ./script.sh`), &actual)
require.NoError(t, err)
require.Equal(t, Hook{
Cmd: "./script.sh",
Env: nil,
}, actual.Pre[0])
}
func TestBuildHook_stringCmds(t *testing.T) {
var actual BuildHookConfig
err := yaml.UnmarshalStrict([]byte(`pre:
- ./script.sh
- second-script.sh
`), &actual)
require.NoError(t, err)
require.Equal(t, Hooks{
{
Cmd: "./script.sh",
Env: nil,
},
{
Cmd: "second-script.sh",
Env: nil,
},
}, actual.Pre)
}
func TestBuildHook_complex(t *testing.T) {
var actual BuildHookConfig
err := yaml.UnmarshalStrict([]byte(`pre:
- cmd: ./script.sh
env:
- TEST=value
`), &actual)
require.NoError(t, err)
require.Equal(t, Hook{
Cmd: "./script.sh",
Env: []string{"TEST=value"},
}, actual.Pre[0])
}