mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-25 14:26:04 +03:00
Trim base URL in the constructor
This commit is contained in:
commit
9c7c641217
@ -20,7 +20,7 @@ import (
|
|||||||
// New initialize client.
|
// New initialize client.
|
||||||
func New(url string, key string) *Client {
|
func New(url string, key string) *Client {
|
||||||
return &Client{
|
return &Client{
|
||||||
URL: url,
|
URL: strings.TrimRight(url, "/"),
|
||||||
Key: key,
|
Key: key,
|
||||||
httpClient: &http.Client{Timeout: time.Minute},
|
httpClient: &http.Client{Timeout: time.Minute},
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,15 @@ func badurlclient() *Client {
|
|||||||
return New(badURL, os.Getenv("RETAILCRM_KEY"))
|
return New(badURL, os.Getenv("RETAILCRM_KEY"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBaseURLTrimmed(t *testing.T) {
|
||||||
|
c1 := New("https://test.retailcrm.pro", "key")
|
||||||
|
c2 := New("https://test.retailcrm.pro/", "key")
|
||||||
|
c3 := New("https://test.retailcrm.pro////", "key")
|
||||||
|
|
||||||
|
assert.Equal(t, c1.URL, c2.URL)
|
||||||
|
assert.Equal(t, c1.URL, c3.URL)
|
||||||
|
}
|
||||||
|
|
||||||
func TestGetRequest(t *testing.T) {
|
func TestGetRequest(t *testing.T) {
|
||||||
c := client()
|
c := client()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user