mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-22 04:46:03 +03:00
46 lines
754 B
Go
46 lines
754 B
Go
package retailcrm
|
|
|
|
import (
|
|
"net/http"
|
|
"net/url"
|
|
"testing"
|
|
)
|
|
|
|
const (
|
|
TestUrl = "https://demo.retailcrm.ru"
|
|
TestApiKey = "111"
|
|
WrongApiKeyMsg = "Wrong \"apiKey\" value."
|
|
)
|
|
|
|
func client() *Client {
|
|
return New(TestUrl, TestApiKey)
|
|
}
|
|
|
|
func TestGetRequest(t *testing.T) {
|
|
c := client()
|
|
|
|
data, status, _ := c.GetRequest("/store/products")
|
|
if status != http.StatusForbidden {
|
|
t.Fail()
|
|
}
|
|
|
|
resp, _ := c.ErrorResponse(data)
|
|
if resp.ErrorMsg != WrongApiKeyMsg {
|
|
t.Fail()
|
|
}
|
|
}
|
|
|
|
func TestPostRequest(t *testing.T) {
|
|
c := client()
|
|
|
|
data, status, _ := c.PostRequest("/orders/create", url.Values{})
|
|
if status != http.StatusForbidden {
|
|
t.Fail()
|
|
}
|
|
|
|
resp, _ := c.ErrorResponse(data)
|
|
if resp.ErrorMsg != WrongApiKeyMsg {
|
|
t.Fail()
|
|
}
|
|
}
|