You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-07-15 01:34:21 +02:00
refactor: better code organization (#757)
* refactor: merging archive in the same repo * refactor: merging archive in the same repo * refactor: better organizing packages * refactor: fixing renames * fix: new dep version * fix: makefile * fix: zip/tar tests * fix: gitigonore * fix: s3 tests * fix: archive test
This commit is contained in:
committed by
GitHub
parent
38e5d3239e
commit
64b1f14a86
126
pkg/config/config_array_test.go
Normal file
126
pkg/config/config_array_test.go
Normal file
@ -0,0 +1,126 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
type Unmarshaled struct {
|
||||
Strings StringArray `yaml:",omitempty"`
|
||||
Flags FlagArray `yaml:",omitempty"`
|
||||
}
|
||||
|
||||
type yamlUnmarshalTestCase struct {
|
||||
yaml string
|
||||
expected Unmarshaled
|
||||
err string
|
||||
}
|
||||
|
||||
var stringArrayTests = []yamlUnmarshalTestCase{
|
||||
{
|
||||
"",
|
||||
Unmarshaled{},
|
||||
"",
|
||||
},
|
||||
{
|
||||
"strings: []",
|
||||
Unmarshaled{
|
||||
Strings: StringArray{},
|
||||
},
|
||||
"",
|
||||
},
|
||||
{
|
||||
"strings: [one two, three]",
|
||||
Unmarshaled{
|
||||
Strings: StringArray{"one two", "three"},
|
||||
},
|
||||
"",
|
||||
},
|
||||
{
|
||||
"strings: one two",
|
||||
Unmarshaled{
|
||||
Strings: StringArray{"one two"},
|
||||
},
|
||||
"",
|
||||
},
|
||||
{
|
||||
"strings: {key: val}",
|
||||
Unmarshaled{},
|
||||
"yaml: unmarshal errors:\n line 1: cannot unmarshal !!map into string",
|
||||
},
|
||||
}
|
||||
|
||||
var flagArrayTests = []yamlUnmarshalTestCase{
|
||||
{
|
||||
"",
|
||||
Unmarshaled{},
|
||||
"",
|
||||
},
|
||||
{
|
||||
"flags: []",
|
||||
Unmarshaled{
|
||||
Flags: FlagArray{},
|
||||
},
|
||||
"",
|
||||
},
|
||||
{
|
||||
"flags: [one two, three]",
|
||||
Unmarshaled{
|
||||
Flags: FlagArray{"one two", "three"},
|
||||
},
|
||||
"",
|
||||
},
|
||||
{
|
||||
"flags: one two",
|
||||
Unmarshaled{
|
||||
Flags: FlagArray{"one", "two"},
|
||||
},
|
||||
"",
|
||||
},
|
||||
{
|
||||
"flags: {key: val}",
|
||||
Unmarshaled{},
|
||||
"yaml: unmarshal errors:\n line 1: cannot unmarshal !!map into string",
|
||||
},
|
||||
}
|
||||
|
||||
func TestStringArray(t *testing.T) {
|
||||
for _, testCase := range stringArrayTests {
|
||||
var actual Unmarshaled
|
||||
|
||||
err := yaml.UnmarshalStrict([]byte(testCase.yaml), &actual)
|
||||
if testCase.err == "" {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, testCase.expected, actual)
|
||||
} else {
|
||||
assert.EqualError(t, err, testCase.err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// func TestStringArrayFailure(t *testing.T) {
|
||||
// var source = `
|
||||
// strings:
|
||||
// key: val
|
||||
// `
|
||||
|
||||
// var actual Unmarshaled
|
||||
// err := yaml.UnmarshalStrict([]byte(source), &actual)
|
||||
// // assert.EqualError(t, err, )
|
||||
// }
|
||||
|
||||
func TestFlagArray(t *testing.T) {
|
||||
for _, testCase := range flagArrayTests {
|
||||
var actual Unmarshaled
|
||||
|
||||
err := yaml.UnmarshalStrict([]byte(testCase.yaml), &actual)
|
||||
if testCase.err == "" {
|
||||
assert.NoError(t, err)
|
||||
} else {
|
||||
assert.EqualError(t, err, testCase.err)
|
||||
}
|
||||
assert.Equal(t, testCase.expected, actual)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user