- Add VPN field to ServerSelection struct - Set VPN type to server selection at start using VPN_TYPE - Change OpenVPNConnection to Connection with Type field - Rename Provider GetOpenVPNConnection to GetConnection - Rename GetTargetIPOpenVPNConnection to GetTargetIPConnection - Rename PickRandomOpenVPNConnection to PickRandomConnection - Add 'OpenVPN' prefix to OpenVPN specific methods on connection
27 lines
655 B
Go
27 lines
655 B
Go
package utils
|
|
|
|
import (
|
|
"math/rand"
|
|
"testing"
|
|
|
|
"github.com/qdm12/gluetun/internal/models"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func Test_PickRandomConnection(t *testing.T) {
|
|
t.Parallel()
|
|
connections := []models.Connection{
|
|
{Port: 1}, {Port: 2}, {Port: 3}, {Port: 4},
|
|
}
|
|
source := rand.NewSource(0)
|
|
|
|
connection := PickRandomConnection(connections, source)
|
|
assert.Equal(t, models.Connection{Port: 3}, connection)
|
|
|
|
connection = PickRandomConnection(connections, source)
|
|
assert.Equal(t, models.Connection{Port: 3}, connection)
|
|
|
|
connection = PickRandomConnection(connections, source)
|
|
assert.Equal(t, models.Connection{Port: 2}, connection)
|
|
}
|