mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-22 05:27:13 +02:00
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:
parent
c6b6141d12
commit
a4c7381eba
22 changed files with 556 additions and 191 deletions
39
config/custom_test.go
Normal file
39
config/custom_test.go
Normal 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)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue