From 19db4e3e0b46352d4f1a4cf8a78be44f16bdb146 Mon Sep 17 00:00:00 2001 From: Adrien Barreau Date: Mon, 9 Oct 2023 14:45:50 +0000 Subject: [PATCH] feat: expose endpoint on client Signed-off-by: Adrien Barreau --- ovh/ovh.go | 4 ++++ ovh/ovh_test.go | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) 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 }