api-client-go/v5/client_test.go

2082 lines
37 KiB
Go
Raw Normal View History

2018-02-27 11:37:15 +03:00
package v5
import (
"fmt"
"math/rand"
"net/http"
"net/url"
"os"
"strconv"
"testing"
"time"
)
var r *rand.Rand // Rand for this package.
var user, _ = strconv.Atoi(os.Getenv("RETAILCRM_USER"))
var statuses = map[int]bool{http.StatusOK: true, http.StatusCreated: true}
func init() {
r = rand.New(rand.NewSource(time.Now().UnixNano()))
}
func RandomString(strlen int) string {
const chars = "abcdefghijklmnopqrstuvwxyz0123456789"
result := make([]byte, strlen)
for i := range result {
result[i] = chars[r.Intn(len(chars))]
}
return string(result)
}
func client() *Client {
return New(os.Getenv("RETAILCRM_URL"), os.Getenv("RETAILCRM_KEY"))
}
func TestGetRequest(t *testing.T) {
c := client()
_, status, _ := c.GetRequest("/fake-method")
if status != http.StatusNotFound {
t.Fail()
}
}
func TestPostRequest(t *testing.T) {
c := client()
_, status, _ := c.PostRequest("/fake-method", url.Values{})
if status != http.StatusNotFound {
t.Fail()
}
}
func TestClient_ApiVersionsVersions(t *testing.T) {
c := client()
data, status, err := c.APIVersions()
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
2018-02-27 11:37:15 +03:00
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
2018-02-27 11:37:15 +03:00
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
2018-02-27 11:37:15 +03:00
t.Fail()
}
}
func TestClient_ApiCredentialsCredentials(t *testing.T) {
c := client()
data, status, err := c.APICredentials()
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Fail()
}
if status >= http.StatusBadRequest {
t.Fail()
}
if data.Success != true {
t.Fail()
}
}
func TestClient_CustomersCustomers(t *testing.T) {
c := client()
data, status, err := c.Customers(CustomersRequest{
Filter: CustomersFilter{
City: "Москва",
},
Page: 3,
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CustomerChange(t *testing.T) {
c := client()
f := Customer{
FirstName: "Понтелей",
LastName: "Турбин",
Patronymic: "Аристархович",
ExternalID: RandomString(8),
2018-02-27 11:37:15 +03:00
Email: fmt.Sprintf("%s@example.com", RandomString(8)),
Address: &Address{
City: "Москва",
Street: "Кутузовский",
Building: "14",
},
}
cr, sc, err := c.CustomerCreate(f)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if sc != http.StatusCreated {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if cr.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
f.ID = cr.ID
2018-02-27 11:37:15 +03:00
f.Vip = true
ed, se, err := c.CustomerEdit(f, "id")
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if se != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if ed.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
data, status, err := c.Customer(f.ExternalID, "externalId", "")
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Customer.ExternalID != f.ExternalID {
2018-02-27 11:37:15 +03:00
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CustomersUpload(t *testing.T) {
c := client()
customers := make([]Customer, 3)
for i := range customers {
customers[i] = Customer{
FirstName: fmt.Sprintf("Name_%s", RandomString(8)),
LastName: fmt.Sprintf("Test_%s", RandomString(8)),
ExternalID: RandomString(8),
2018-02-27 11:37:15 +03:00
Email: fmt.Sprintf("%s@example.com", RandomString(8)),
}
}
data, status, err := c.CustomersUpload(customers)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CustomersCombine(t *testing.T) {
c := client()
dataFirst, status, err := c.CustomerCreate(Customer{
FirstName: fmt.Sprintf("Name_%s", RandomString(8)),
LastName: fmt.Sprintf("Test_%s", RandomString(8)),
ExternalID: RandomString(8),
2018-02-27 11:37:15 +03:00
Email: fmt.Sprintf("%s@example.com", RandomString(8)),
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if dataFirst.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
dataSecond, status, err := c.CustomerCreate(Customer{
FirstName: fmt.Sprintf("Name_%s", RandomString(8)),
LastName: fmt.Sprintf("Test_%s", RandomString(8)),
ExternalID: RandomString(8),
2018-02-27 11:37:15 +03:00
Email: fmt.Sprintf("%s@example.com", RandomString(8)),
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if dataSecond.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
dataThird, status, err := c.CustomerCreate(Customer{
FirstName: fmt.Sprintf("Name_%s", RandomString(8)),
LastName: fmt.Sprintf("Test_%s", RandomString(8)),
ExternalID: RandomString(8),
2018-02-27 11:37:15 +03:00
Email: fmt.Sprintf("%s@example.com", RandomString(8)),
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if dataThird.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
data, status, err := c.CustomersCombine([]Customer{{ID: dataFirst.ID}, {ID: dataSecond.ID}}, Customer{ID: dataThird.ID})
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CustomersFixExternalIds(t *testing.T) {
c := client()
f := Customer{
FirstName: fmt.Sprintf("Name_%s", RandomString(8)),
LastName: fmt.Sprintf("Test_%s", RandomString(8)),
ExternalID: RandomString(8),
2018-02-27 11:37:15 +03:00
Email: fmt.Sprintf("%s@example.com", RandomString(8)),
}
cr, sc, err := c.CustomerCreate(f)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if sc != http.StatusCreated {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if cr.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
customers := []IdentifiersPair{{
ID: cr.ID,
ExternalID: RandomString(8),
2018-02-27 11:37:15 +03:00
}}
fx, fe, err := c.CustomersFixExternalIds(customers)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if fe != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if fx.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CustomersHistory(t *testing.T) {
c := client()
f := CustomersHistoryRequest{
Filter: CustomersHistoryFilter{
SinceID: 20,
2018-02-27 11:37:15 +03:00
},
}
data, status, err := c.CustomersHistory(f)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if len(data.History) == 0 {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_NotesNotes(t *testing.T) {
c := client()
data, status, err := c.CustomerNotes(NotesRequest{Page: 1})
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_NotesCreateDelete(t *testing.T) {
c := client()
createCustomerResponse, createCustomerStatus, err := c.CustomerCreate(Customer{
FirstName: "Понтелей",
LastName: "Турбин",
Patronymic: "Аристархович",
ExternalID: RandomString(8),
2018-02-27 11:37:15 +03:00
Email: fmt.Sprintf("%s@example.com", RandomString(8)),
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if createCustomerStatus != http.StatusCreated {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if createCustomerResponse.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
noteCreateResponse, noteCreateStatus, err := c.CustomerNoteCreate(Note{
2018-02-27 11:37:15 +03:00
Text: "some text",
ManagerID: user,
2018-02-27 11:37:15 +03:00
Customer: &Customer{
ID: createCustomerResponse.ID,
2018-02-27 11:37:15 +03:00
},
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if noteCreateStatus != http.StatusCreated {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if noteCreateResponse.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
noteDeleteResponse, noteDeleteStatus, err := c.CustomerNoteDelete(noteCreateResponse.ID)
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if noteDeleteStatus != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if noteDeleteResponse.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_OrdersOrders(t *testing.T) {
c := client()
data, status, err := c.Orders(OrdersRequest{Filter: OrdersFilter{City: "Москва"}, Page: 1})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_OrderChange(t *testing.T) {
c := client()
random := RandomString(8)
f := Order{
FirstName: "Понтелей",
LastName: "Турбин",
Patronymic: "Аристархович",
ExternalID: random,
2018-02-27 11:37:15 +03:00
Email: fmt.Sprintf("%s@example.com", random),
}
cr, sc, err := c.OrderCreate(f)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if sc != http.StatusCreated {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if cr.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
f.ID = cr.ID
2018-02-27 11:37:15 +03:00
f.CustomerComment = "test comment"
ed, se, err := c.OrderEdit(f, "id")
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if se != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if ed.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
data, status, err := c.Order(f.ExternalID, "externalId", "")
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Order.ExternalID != f.ExternalID {
2018-02-27 11:37:15 +03:00
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_OrdersUpload(t *testing.T) {
c := client()
orders := make([]Order, 3)
for i := range orders {
orders[i] = Order{
FirstName: fmt.Sprintf("Name_%s", RandomString(8)),
LastName: fmt.Sprintf("Test_%s", RandomString(8)),
ExternalID: RandomString(8),
2018-02-27 11:37:15 +03:00
Email: fmt.Sprintf("%s@example.com", RandomString(8)),
}
}
data, status, err := c.OrdersUpload(orders)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_OrdersCombine(t *testing.T) {
c := client()
dataFirst, status, err := c.OrderCreate(Order{
FirstName: fmt.Sprintf("Name_%s", RandomString(8)),
LastName: fmt.Sprintf("Test_%s", RandomString(8)),
ExternalID: RandomString(8),
2018-02-27 11:37:15 +03:00
Email: fmt.Sprintf("%s@example.com", RandomString(8)),
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if dataFirst.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
dataSecond, status, err := c.OrderCreate(Order{
FirstName: fmt.Sprintf("Name_%s", RandomString(8)),
LastName: fmt.Sprintf("Test_%s", RandomString(8)),
ExternalID: RandomString(8),
2018-02-27 11:37:15 +03:00
Email: fmt.Sprintf("%s@example.com", RandomString(8)),
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if dataSecond.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
data, status, err := c.OrdersCombine("ours", Order{ID: dataFirst.ID}, Order{ID: dataSecond.ID})
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_OrdersFixExternalIds(t *testing.T) {
c := client()
f := Order{
FirstName: fmt.Sprintf("Name_%s", RandomString(8)),
LastName: fmt.Sprintf("Test_%s", RandomString(8)),
ExternalID: RandomString(8),
2018-02-27 11:37:15 +03:00
Email: fmt.Sprintf("%s@example.com", RandomString(8)),
}
cr, sc, err := c.OrderCreate(f)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if sc != http.StatusCreated {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if cr.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
orders := []IdentifiersPair{{
ID: cr.ID,
ExternalID: RandomString(8),
2018-02-27 11:37:15 +03:00
}}
fx, fe, err := c.OrdersFixExternalIds(orders)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if fe != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if fx.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_OrdersHistory(t *testing.T) {
c := client()
data, status, err := c.OrdersHistory(OrdersHistoryRequest{Filter: OrdersHistoryFilter{SinceID: 20}})
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if len(data.History) == 0 {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_PaymentCreateEditDelete(t *testing.T) {
c := client()
order := Order{
FirstName: "Понтелей",
LastName: "Турбин",
Patronymic: "Аристархович",
ExternalID: RandomString(8),
2018-02-27 11:37:15 +03:00
Email: fmt.Sprintf("%s@example.com", RandomString(8)),
}
createOrderResponse, status, err := c.OrderCreate(order)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusCreated {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if createOrderResponse.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
f := Payment{
Order: &Order{
ID: createOrderResponse.ID,
2018-02-27 11:37:15 +03:00
},
Amount: 300,
Type: "cash",
}
paymentCreateResponse, status, err := c.OrderPaymentCreate(f)
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusCreated {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if paymentCreateResponse.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
k := Payment{
ID: paymentCreateResponse.ID,
2018-02-27 11:37:15 +03:00
Amount: 500,
}
paymentEditResponse, status, err := c.OrderPaymentEdit(k, "id")
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if paymentEditResponse.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
paymentDeleteResponse, status, err := c.OrderPaymentDelete(paymentCreateResponse.ID)
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if paymentDeleteResponse.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_TasksTasks(t *testing.T) {
c := client()
f := TasksRequest{
Filter: TasksFilter{
Creators: []int{user},
},
Page: 1,
}
data, status, err := c.Tasks(f)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_TaskChange(t *testing.T) {
c := client()
f := Task{
Text: RandomString(15),
PerformerID: user,
2018-02-27 11:37:15 +03:00
}
cr, sc, err := c.TaskCreate(f)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if sc != http.StatusCreated {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if cr.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
f.ID = cr.ID
2018-02-27 11:37:15 +03:00
f.Commentary = RandomString(20)
gt, sg, err := c.Task(f.ID)
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if sg != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if gt.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
data, status, err := c.TaskEdit(f)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_UsersUsers(t *testing.T) {
c := client()
data, status, err := c.Users(UsersRequest{Filter: UsersFilter{Active: 1}, Page: 1})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_UsersUser(t *testing.T) {
c := client()
data, st, err := c.User(user)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_UsersGroups(t *testing.T) {
c := client()
data, status, err := c.UserGroups(UserGroupsRequest{Page: 1})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_UsersUpdate(t *testing.T) {
c := client()
data, st, err := c.UserStatus(user, "busy")
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_StaticticsUpdate(t *testing.T) {
2018-02-27 11:37:15 +03:00
c := client()
data, st, err := c.StaticticsUpdate()
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_Countries(t *testing.T) {
c := client()
data, st, err := c.Couriers()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CostGroups(t *testing.T) {
c := client()
data, st, err := c.CostGroups()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CostItems(t *testing.T) {
c := client()
data, st, err := c.CostItems()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_Couriers(t *testing.T) {
c := client()
data, st, err := c.Couriers()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_DeliveryService(t *testing.T) {
c := client()
data, st, err := c.DeliveryServices()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_DeliveryTypes(t *testing.T) {
c := client()
data, st, err := c.DeliveryTypes()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_LegalEntities(t *testing.T) {
c := client()
data, st, err := c.LegalEntities()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_OrderMethods(t *testing.T) {
c := client()
data, st, err := c.OrderMethods()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_OrderTypes(t *testing.T) {
c := client()
data, st, err := c.OrderTypes()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_PaymentStatuses(t *testing.T) {
c := client()
data, st, err := c.PaymentStatuses()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_PaymentTypes(t *testing.T) {
c := client()
data, st, err := c.PaymentTypes()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_PriceTypes(t *testing.T) {
c := client()
data, st, err := c.PriceTypes()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_ProductStatuses(t *testing.T) {
c := client()
data, st, err := c.ProductStatuses()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_Statuses(t *testing.T) {
c := client()
data, st, err := c.Statuses()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_StatusGroups(t *testing.T) {
c := client()
data, st, err := c.StatusGroups()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_Sites(t *testing.T) {
c := client()
data, st, err := c.Sites()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_Stores(t *testing.T) {
c := client()
data, st, err := c.Stores()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if st != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CostGroupItemEdit(t *testing.T) {
c := client()
uid := RandomString(4)
data, st, err := c.CostGroupEdit(CostGroup{
Code: fmt.Sprintf("cost-gr-%s", uid),
Active: false,
Color: "#da5c98",
Name: fmt.Sprintf("CostGroup-%s", uid),
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if !statuses[st] {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
idata, st, err := c.CostItemEdit(CostItem{
Code: fmt.Sprintf("cost-it-%s", uid),
Name: fmt.Sprintf("CostItem-%s", uid),
Group: fmt.Sprintf("cost-gr-%s", uid),
Type: "const",
AppliesToOrders: true,
Active: false,
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if !statuses[st] {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if idata.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_Courier(t *testing.T) {
c := client()
cur := Courier{
Active: true,
Email: fmt.Sprintf("%s@example.com", RandomString(5)),
FirstName: fmt.Sprintf("%s", RandomString(5)),
LastName: fmt.Sprintf("%s", RandomString(5)),
}
data, st, err := c.CourierCreate(cur)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if !statuses[st] {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
cur.ID = data.ID
2018-02-27 11:37:15 +03:00
cur.Patronymic = fmt.Sprintf("%s", RandomString(5))
idata, st, err := c.CourierEdit(cur)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if !statuses[st] {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if idata.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_DeliveryServiceEdit(t *testing.T) {
c := client()
data, st, err := c.DeliveryServiceEdit(DeliveryService{
Active: false,
Code: RandomString(5),
Name: RandomString(5),
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if !statuses[st] {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_DeliveryTypeEdit(t *testing.T) {
c := client()
x := []string{"cash", "bank-card"}
data, st, err := c.DeliveryTypeEdit(DeliveryType{
Active: false,
Code: RandomString(5),
Name: RandomString(5),
DefaultCost: 300,
PaymentTypes: x,
DefaultForCrm: false,
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if !statuses[st] {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_OrderMethodEdit(t *testing.T) {
c := client()
data, st, err := c.OrderMethodEdit(OrderMethod{
Code: RandomString(5),
Name: RandomString(5),
Active: false,
DefaultForCRM: false,
2018-02-27 11:37:15 +03:00
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if !statuses[st] {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_OrderTypeEdit(t *testing.T) {
c := client()
data, st, err := c.OrderTypeEdit(OrderType{
Code: RandomString(5),
Name: RandomString(5),
Active: false,
DefaultForCRM: false,
2018-02-27 11:37:15 +03:00
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if !statuses[st] {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_PaymentStatusEdit(t *testing.T) {
c := client()
data, st, err := c.PaymentStatusEdit(PaymentStatus{
Code: RandomString(5),
Name: RandomString(5),
Active: false,
DefaultForCRM: false,
2018-02-27 11:37:15 +03:00
PaymentTypes: []string{"cash"},
PaymentComplete: false,
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if !statuses[st] {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_PaymentTypeEdit(t *testing.T) {
c := client()
data, st, err := c.PaymentTypeEdit(PaymentType{
Code: RandomString(5),
Name: RandomString(5),
Active: false,
DefaultForCRM: false,
2018-02-27 11:37:15 +03:00
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if !statuses[st] {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_PriceTypeEdit(t *testing.T) {
c := client()
data, st, err := c.PriceTypeEdit(PriceType{
Code: RandomString(5),
Name: RandomString(5),
Active: false,
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if !statuses[st] {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_ProductStatusEdit(t *testing.T) {
c := client()
data, st, err := c.ProductStatusEdit(ProductStatus{
Code: RandomString(5),
Name: RandomString(5),
Active: false,
CancelStatus: false,
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if !statuses[st] {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_StatusEdit(t *testing.T) {
c := client()
data, st, err := c.StatusEdit(Status{
Code: RandomString(5),
Name: RandomString(5),
Active: false,
Group: "new",
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if !statuses[st] {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_SiteEdit(t *testing.T) {
c := client()
data, _, err := c.SiteEdit(Site{
Code: RandomString(5),
Name: RandomString(5),
URL: fmt.Sprintf("https://%s.example.com", RandomString(4)),
2018-02-27 11:37:15 +03:00
LoadFromYml: false,
})
if err.ErrorMsg == "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != false {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_StoreEdit(t *testing.T) {
c := client()
data, st, err := c.StoreEdit(Store{
Code: RandomString(5),
Name: RandomString(5),
Active: false,
Type: "store-type-warehouse",
InventoryType: "integer",
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if !statuses[st] {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_PackChange(t *testing.T) {
c := client()
o, status, err := c.OrderCreate(Order{
FirstName: "Понтелей",
LastName: "Турбин",
Patronymic: "Аристархович",
ExternalID: RandomString(8),
2018-02-27 11:37:15 +03:00
Email: fmt.Sprintf("%s@example.com", RandomString(8)),
Items: []OrderItem{{Offer: Offer{ID: 1609}, Quantity: 5}},
2018-02-27 11:37:15 +03:00
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusCreated {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if o.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
g, status, err := c.Order(strconv.Itoa(o.ID), "id", "")
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if o.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
p, status, err := c.PackCreate(Pack{
Store: "test-store",
ItemID: g.Order.Items[0].ID,
2018-02-27 11:37:15 +03:00
Quantity: 1,
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusCreated {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if p.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
s, status, err := c.Pack(p.ID)
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if s.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
e, status, err := c.PackEdit(Pack{ID: p.ID, Quantity: 2})
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if e.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
d, status, err := c.PackDelete(p.ID)
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if d.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_PacksHistory(t *testing.T) {
c := client()
data, status, err := c.PacksHistory(PacksHistoryRequest{Filter: OrdersHistoryFilter{SinceID: 5}})
2018-02-27 11:37:15 +03:00
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if len(data.History) == 0 {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_Packs(t *testing.T) {
c := client()
data, status, err := c.Packs(PacksRequest{Filter: PacksFilter{}, Page: 1})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_Inventories(t *testing.T) {
c := client()
data, status, err := c.Inventories(InventoriesRequest{Filter: InventoriesFilter{Details: 1}, Page: 1})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_Segments(t *testing.T) {
c := client()
data, status, err := c.Segments(SegmentsRequest{})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_IntegrationModule(t *testing.T) {
c := client()
name := RandomString(5)
code := RandomString(8)
m, status, err := c.IntegrationModuleEdit(IntegrationModule{
Code: code,
IntegrationCode: code,
Active: false,
Name: fmt.Sprintf("Integration module %s", name),
AccountURL: fmt.Sprintf("http://example.com/%s/account", name),
BaseURL: fmt.Sprintf("http://example.com/%s", name),
ClientID: RandomString(10),
2018-02-27 11:37:15 +03:00
Logo: "https://cdn.worldvectorlogo.com/logos/github-icon.svg",
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusCreated {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if m.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
g, status, err := c.IntegrationModule(code)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if g.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_IntegrationModuleFail(t *testing.T) {
c := client()
code := RandomString(8)
m, status, err := c.IntegrationModuleEdit(IntegrationModule{
Code: code,
})
if err.ErrorMsg == "" {
t.Fail()
}
if status < http.StatusBadRequest {
t.Fail()
}
if m.Success != false {
t.Fail()
}
g, status, err := c.IntegrationModule(RandomString(12))
if err.ErrorMsg == "" {
t.Fail()
}
if status < http.StatusBadRequest {
t.Fail()
}
if g.Success != false {
t.Fail()
}
}
func TestClient_ProductsGroup(t *testing.T) {
c := client()
g, status, err := c.ProductsGroup(ProductsGroupsRequest{
Filter: ProductsGroupsFilter{
Active: 1,
},
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if g.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_Products(t *testing.T) {
c := client()
g, status, err := c.Products(ProductsRequest{
Filter: ProductsFilter{
Active: 1,
MinPrice: 1,
},
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if g.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_ProductsProperties(t *testing.T) {
c := client()
sites := make([]string, 1)
sites[0] = os.Getenv("RETAILCRM_SITE")
g, status, err := c.ProductsProperties(ProductsPropertiesRequest{
Filter: ProductsPropertiesFilter{
Sites: sites,
},
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if g.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_DeliveryShipments(t *testing.T) {
c := client()
g, status, err := c.DeliveryShipments(DeliveryShipmentsRequest{
Filter: ShipmentFilter{
DateFrom: "2017-10-10",
},
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if g.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}