1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-06 03:13:48 +02:00
goreleaser/pkg/config/config_build_hook_test.go
Carlos Alexandro Becker 979f8632b7
refactor: use require on all tests (#1839)
* refactor: use require on all tests

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* refactor: use require on all tests

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-10-06 12:48:04 +00:00

56 lines
975 B
Go

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