config: support multiple destination addresses (#1789)

* config: support multiple destination addresses

* use constructor for string slice

* add docs

* add test for multiple destinations

* fix name
This commit is contained in:
Caleb Doxsey 2021-01-20 15:18:24 -07:00 committed by GitHub
parent c6b6141d12
commit a4c7381eba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 556 additions and 191 deletions

39
config/custom_test.go Normal file
View file

@ -0,0 +1,39 @@
package config
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"
)
func TestStringSlice_UnmarshalJSON(t *testing.T) {
t.Run("string", func(t *testing.T) {
var slc StringSlice
json.Unmarshal([]byte(`"hello world"`), &slc)
assert.Equal(t, NewStringSlice("hello world"), slc)
})
t.Run("array", func(t *testing.T) {
var slc StringSlice
json.Unmarshal([]byte(`["a","b","c"]`), &slc)
assert.Equal(t, NewStringSlice("a", "b", "c"), slc)
})
}
func TestStringSlice_UnmarshalYAML(t *testing.T) {
t.Run("string", func(t *testing.T) {
var slc StringSlice
yaml.Unmarshal([]byte(`hello world`), &slc)
assert.Equal(t, NewStringSlice("hello world"), slc)
})
t.Run("array", func(t *testing.T) {
var slc StringSlice
yaml.Unmarshal([]byte(`
- a
- b
- c
`), &slc)
assert.Equal(t, NewStringSlice("a", "b", "c"), slc)
})
}