12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package v1
- import (
- "encoding/json"
- "testing"
- "github.com/stretchr/testify/require"
- )
- func TestUnmarshalTypedProxyConfig(t *testing.T) {
- require := require.New(t)
- proxyConfigs := struct {
- Proxies []TypedProxyConfig `json:"proxies,omitempty"`
- }{}
- strs := `{
- "proxies": [
- {
- "type": "tcp",
- "localPort": 22,
- "remotePort": 6000
- },
- {
- "type": "http",
- "localPort": 80,
- "customDomains": ["www.example.com"]
- }
- ]
- }`
- err := json.Unmarshal([]byte(strs), &proxyConfigs)
- require.NoError(err)
- require.IsType(&TCPProxyConfig{}, proxyConfigs.Proxies[0].ProxyConfigurer)
- require.IsType(&HTTPProxyConfig{}, proxyConfigs.Proxies[1].ProxyConfigurer)
- }
|