From 50e25d61bc227609f7e7d363c893fad82e78d71c Mon Sep 17 00:00:00 2001 From: Ruslan Efanov Date: Tue, 6 Dec 2022 22:27:56 +0300 Subject: [PATCH] change type on active field --- client_test.go | 21 +++++++++++++++------ types.go | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/client_test.go b/client_test.go index 1097f62..317c30a 100644 --- a/client_test.go +++ b/client_test.go @@ -5118,7 +5118,7 @@ func TestClient_IntegrationModule(t *testing.T) { integrationModule := IntegrationModule{ Code: code, IntegrationCode: code, - Active: false, + Active: new(bool), Name: fmt.Sprintf("Integration module %s", name), AccountURL: fmt.Sprintf("http://example.com/%s/account", name), BaseURL: fmt.Sprintf("http://example.com/%s", name), @@ -5126,10 +5126,13 @@ func TestClient_IntegrationModule(t *testing.T) { Logo: "https://cdn.worldvectorlogo.com/logos/github-icon.svg", } - jr, _ := json.Marshal(&integrationModule) + jsonData := fmt.Sprintf( + `{"code":"%s","integrationCode":"%s","active":false,"name":"%s","logo":"%s","clientId":"%s","baseUrl":"%s","accountUrl":"%s"}`, + code, code, integrationModule.Name, integrationModule.Logo, integrationModule.ClientID, integrationModule.BaseURL, integrationModule.AccountURL, + ) pr := url.Values{ - "integrationModule": {string(jr[:])}, + "integrationModule": {jsonData}, } gock.New(crmURL). @@ -5179,9 +5182,12 @@ func TestClient_IntegrationModule_Fail(t *testing.T) { defer gock.Off() + active := new(bool) + *active = true + integrationModule := IntegrationModule{ IntegrationCode: code, - Active: false, + Active: active, Name: fmt.Sprintf("Integration module %s", name), AccountURL: fmt.Sprintf("http://example.com/%s/account", name), BaseURL: fmt.Sprintf("http://example.com/%s", name), @@ -5189,10 +5195,13 @@ func TestClient_IntegrationModule_Fail(t *testing.T) { Logo: "https://cdn.worldvectorlogo.com/logos/github-icon.svg", } - jr, _ := json.Marshal(&integrationModule) + jsonData := fmt.Sprintf( + `{"integrationCode":"%s","active":true,"name":"%s","logo":"%s","clientId":"%s","baseUrl":"%s","accountUrl":"%s"}`, + code, integrationModule.Name, integrationModule.Logo, integrationModule.ClientID, integrationModule.BaseURL, integrationModule.AccountURL, + ) pr := url.Values{ - "integrationModule": {string(jr[:])}, + "integrationModule": {jsonData}, } gock.New(crmURL). diff --git a/types.go b/types.go index fd1c3af..4263439 100644 --- a/types.go +++ b/types.go @@ -975,7 +975,7 @@ type DeliveryShipment struct { type IntegrationModule struct { Code string `json:"code,omitempty"` IntegrationCode string `json:"integrationCode,omitempty"` - Active bool `json:"active"` + Active *bool `json:"active,omitempty"` Freeze bool `json:"freeze,omitempty"` Native bool `json:"native,omitempty"` Name string `json:"name,omitempty"`