diff --git a/ovh/ovh.go b/ovh/ovh.go index 9c47e43..950fd37 100644 --- a/ovh/ovh.go +++ b/ovh/ovh.go @@ -114,6 +114,10 @@ func NewDefaultClient() (*Client, error) { return NewClient("", "", "", "") } +func (c *Client) Endpoint() string { + return c.endpoint +} + // // High level helpers // diff --git a/ovh/ovh_test.go b/ovh/ovh_test.go index 66bde9e..381d4d2 100644 --- a/ovh/ovh_test.go +++ b/ovh/ovh_test.go @@ -38,6 +38,22 @@ func sbody(s string) io.ReadCloser { // Tests // +func TestClientEndpoint(t *testing.T) { + require := td.Require(t) + + client, err := NewClient("ovh-eu", MockApplicationKey, MockApplicationSecret, MockConsumerKey) + require.CmpNoError(err) + td.Cmp(t, client.Endpoint(), OvhEU) + + client, err = NewClient("ovh-ca", MockApplicationKey, MockApplicationSecret, MockConsumerKey) + require.CmpNoError(err) + td.Cmp(t, client.Endpoint(), OvhCA) + + client, err = NewClient("https://example.org", MockApplicationKey, MockApplicationSecret, MockConsumerKey) + require.CmpNoError(err) + td.Cmp(t, client.Endpoint(), "https://example.org") +} + type MockSuite struct { client *Client }