-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resell V2 - add client with a custom endpoint
Users may want to use custom endpoint for the Resell V2 API. This commit adds a new NewV2ResellClientWithEndpoint method, fixes argument capitalization in the old NewV2ResellClient method and adds simple tests.
- Loading branch information
1 parent
b35746b
commit 7a0330f
Showing
2 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package v2 | ||
|
||
import ( | ||
"net/http" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/selectel/go-selvpcclient/selvpcclient" | ||
"github.com/selectel/go-selvpcclient/selvpcclient/resell" | ||
) | ||
|
||
func TestNewV2ResellClient(t *testing.T) { | ||
token := "fakeID" | ||
expected := &selvpcclient.ServiceClient{ | ||
HTTPClient: &http.Client{}, | ||
Endpoint: resell.Endpoint + "/" + APIVersion, | ||
TokenID: token, | ||
UserAgent: resell.UserAgent, | ||
} | ||
|
||
actual := NewV2ResellClient(token) | ||
|
||
if !reflect.DeepEqual(expected, actual) { | ||
t.Fatalf("expected %#v, but got %#v", expected, actual) | ||
} | ||
} | ||
|
||
func TestNewV2ResellClientWithEndpoint(t *testing.T) { | ||
token := "fakeID" | ||
endpoint := "http://example.org" | ||
expected := &selvpcclient.ServiceClient{ | ||
HTTPClient: &http.Client{}, | ||
Endpoint: endpoint, | ||
TokenID: token, | ||
UserAgent: resell.UserAgent, | ||
} | ||
|
||
actual := NewV2ResellClientWithEndpoint(token, endpoint) | ||
|
||
if !reflect.DeepEqual(expected, actual) { | ||
t.Fatalf("expected %#v, but got %#v", expected, actual) | ||
} | ||
} |