UDP support
Co-authored-by: Julien Salleyron <julien.salleyron@gmail.com>
This commit is contained in:
parent
8988c8f9af
commit
115d42e0f0
72 changed files with 4730 additions and 321 deletions
67
pkg/config/static/entrypoints_test.go
Normal file
67
pkg/config/static/entrypoints_test.go
Normal file
|
@ -0,0 +1,67 @@
|
|||
package static
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestEntryPointProtocol(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
address string
|
||||
expectedAddress string
|
||||
expectedProtocol string
|
||||
expectedError bool
|
||||
}{
|
||||
{
|
||||
name: "Without protocol",
|
||||
address: "127.0.0.1:8080",
|
||||
expectedAddress: "127.0.0.1:8080",
|
||||
expectedProtocol: "tcp",
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "With TCP protocol in upper case",
|
||||
address: "127.0.0.1:8080/TCP",
|
||||
expectedAddress: "127.0.0.1:8080",
|
||||
expectedProtocol: "tcp",
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "With UDP protocol in upper case",
|
||||
address: "127.0.0.1:8080/UDP",
|
||||
expectedAddress: "127.0.0.1:8080",
|
||||
expectedProtocol: "udp",
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "With UDP protocol in weird case",
|
||||
address: "127.0.0.1:8080/uDp",
|
||||
expectedAddress: "127.0.0.1:8080",
|
||||
expectedProtocol: "udp",
|
||||
expectedError: false,
|
||||
},
|
||||
|
||||
{
|
||||
name: "With invalid protocol",
|
||||
address: "127.0.0.1:8080/toto/tata",
|
||||
expectedError: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ep := EntryPoint{
|
||||
Address: tt.address,
|
||||
}
|
||||
protocol, err := ep.GetProtocol()
|
||||
if tt.expectedError {
|
||||
require.Error(t, err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tt.expectedProtocol, protocol)
|
||||
require.Equal(t, tt.expectedAddress, ep.GetAddress())
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue