mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-01 19:36:32 +02:00
* config: support multiple destination addresses * use constructor for string slice * add docs * add test for multiple destinations * fix name
39 lines
882 B
Go
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)
|
|
})
|
|
}
|