mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-01-11 18:08:57 +08:00
69fb3b26d3
Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
51 lines
909 B
Go
51 lines
909 B
Go
package ovh
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/ovh/go-ovh/ovh"
|
|
)
|
|
|
|
func Test_getOVHEndpoint(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
endpoint string
|
|
want string
|
|
}{
|
|
{
|
|
"default to EU", "", ovh.OvhEU,
|
|
},
|
|
{
|
|
"default to EU if omitted", "omitted", ovh.OvhEU,
|
|
},
|
|
{
|
|
"set to EU", "eu", ovh.OvhEU,
|
|
},
|
|
{
|
|
"set to CA", "ca", ovh.OvhCA,
|
|
},
|
|
{
|
|
"set to US", "us", ovh.OvhUS,
|
|
},
|
|
{
|
|
"case insensitive", "Eu", ovh.OvhEU,
|
|
},
|
|
{
|
|
"case insensitive ca", "CA", ovh.OvhCA,
|
|
},
|
|
{
|
|
"arbitratry", "https://blah", "https://blah",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
params := make(map[string]string)
|
|
if tt.endpoint != "" && tt.endpoint != "omitted" {
|
|
params["endpoint"] = tt.endpoint
|
|
}
|
|
if got := getOVHEndpoint(params); got != tt.want {
|
|
t.Errorf("getOVHEndpoint() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|