Maint: common GetProtocol for OpenVPN+Wireguard providers

This commit is contained in:
Quentin McGaw (desktop)
2021-08-23 16:07:47 +00:00
parent 06a2d79cb4
commit dbf5c569ea
8 changed files with 70 additions and 155 deletions

View File

@@ -158,42 +158,3 @@ func Test_getPort(t *testing.T) {
})
}
}
func Test_getProtocol(t *testing.T) {
t.Parallel()
testCases := map[string]struct {
selection configuration.ServerSelection
protocol string
}{
"OpenVPN UDP": {
protocol: constants.UDP,
},
"OpenVPN TCP": {
selection: configuration.ServerSelection{
VPN: constants.OpenVPN,
OpenVPN: configuration.OpenVPNSelection{
TCP: true,
},
},
protocol: constants.TCP,
},
"Wireguard": {
selection: configuration.ServerSelection{
VPN: constants.Wireguard,
},
protocol: constants.UDP,
},
}
for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()
protocol := getProtocol(testCase.selection)
assert.Equal(t, testCase.protocol, protocol)
})
}
}