chore(constants): internal/constants/providers

- New package to avoid package import cycles
This commit is contained in:
Quentin McGaw
2022-04-16 19:30:26 +00:00
parent ad80e0c1ab
commit 54b7e23974
51 changed files with 335 additions and 339 deletions

View File

@@ -8,6 +8,7 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -23,7 +24,7 @@ func Test_Provider_GetConnection(t *testing.T) {
err error
}{
"no server available": {
selection: settings.ServerSelection{}.WithDefaults(constants.Expressvpn),
selection: settings.ServerSelection{}.WithDefaults(providers.Expressvpn),
err: errors.New("no server found: for VPN openvpn; protocol udp"),
},
"no filter": {
@@ -32,7 +33,7 @@ func Test_Provider_GetConnection(t *testing.T) {
{IPs: []net.IP{net.IPv4(2, 2, 2, 2)}, UDP: true},
{IPs: []net.IP{net.IPv4(3, 3, 3, 3)}, UDP: true},
},
selection: settings.ServerSelection{}.WithDefaults(constants.Expressvpn),
selection: settings.ServerSelection{}.WithDefaults(providers.Expressvpn),
connection: models.Connection{
Type: constants.OpenVPN,
IP: net.IPv4(1, 1, 1, 1),
@@ -43,7 +44,7 @@ func Test_Provider_GetConnection(t *testing.T) {
"target IP": {
selection: settings.ServerSelection{
TargetIP: net.IPv4(2, 2, 2, 2),
}.WithDefaults(constants.Expressvpn),
}.WithDefaults(providers.Expressvpn),
servers: []models.ExpressvpnServer{
{IPs: []net.IP{net.IPv4(1, 1, 1, 1)}, UDP: true},
{IPs: []net.IP{net.IPv4(2, 2, 2, 2)}, UDP: true},
@@ -59,7 +60,7 @@ func Test_Provider_GetConnection(t *testing.T) {
"with filter": {
selection: settings.ServerSelection{
Hostnames: []string{"b"},
}.WithDefaults(constants.Expressvpn),
}.WithDefaults(providers.Expressvpn),
servers: []models.ExpressvpnServer{
{Hostname: "a", IPs: []net.IP{net.IPv4(1, 1, 1, 1)}, UDP: true},
{Hostname: "b", IPs: []net.IP{net.IPv4(2, 2, 2, 2)}, UDP: true},