pomerium/config/custom_test.go
Caleb Doxsey a4c7381eba
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
2021-01-20 15:18:24 -07:00

39 lines
882 B
Go

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)
})
}