add method for updating product characteristics
This commit is contained in:
@@ -2487,3 +2487,65 @@ func TestNumberOfSubsToProductAvailability(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateCharacteristics(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
statusCode int
|
||||
headers map[string]string
|
||||
params *UpdateCharacteristicsParams
|
||||
response string
|
||||
}{
|
||||
// Test Ok
|
||||
{
|
||||
http.StatusOK,
|
||||
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
|
||||
&UpdateCharacteristicsParams{
|
||||
Items: []UpdateCharacteristicsItem{
|
||||
{
|
||||
Attributes: []UpdateCharacteristicsItemAttribute{
|
||||
{
|
||||
ComplexId: 0,
|
||||
Id: 0,
|
||||
Values: []UpdateCharacteristicsItemValue{
|
||||
{
|
||||
DictionaryValueId: 0,
|
||||
Value: "string",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
OfferId: "string",
|
||||
},
|
||||
},
|
||||
},
|
||||
`{
|
||||
"task_id": 0
|
||||
}`,
|
||||
},
|
||||
// Test No Client-Id or Api-Key
|
||||
{
|
||||
http.StatusUnauthorized,
|
||||
map[string]string{},
|
||||
&UpdateCharacteristicsParams{},
|
||||
`{
|
||||
"code": 16,
|
||||
"message": "Client-Id and Api-Key headers are required"
|
||||
}`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
|
||||
|
||||
resp, err := c.Products().UpdateCharacteristics(test.params)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user