This repository has been archived by the owner on May 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfeeds_test.go
108 lines (102 loc) · 3.38 KB
/
feeds_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package mws
import (
"strconv"
"testing"
)
func TestFeedService_SubmitFeed(t *testing.T) {
xmlBody := []byte(`<?xml version="1.0" encoding="iso-8859-1"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>M_EXAMPLE_123456</MerchantIdentifier>
</Header>
<MessageType>Product</MessageType>
<PurgeAndReplace>false</PurgeAndReplace>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Product>
<SKU>56789</SKU>
<StandardProductID>
<Type>ASIN</Type>
<Value>B0EXAMPLEG</Value>
</StandardProductID>
<ProductTaxCode>A_GEN_NOTAX</ProductTaxCode>
<DescriptionData>
<Title>Example Product Title</Title>
<Brand>Example Product Brand</Brand>
<Description>This is an example product description.</Description>
<BulletPoint>Example Bullet Point 1</BulletPoint>
<BulletPoint>Example Bullet Point 2</BulletPoint>
<MSRP currency="USD">25.19</MSRP>
<Manufacturer>Example Product Manufacturer</Manufacturer>
<ItemType>example-item-type</ItemType>
</DescriptionData>
<ProductData>
<Health>
<ProductType>
<HealthMisc>
<Ingredients>Example Ingredients</Ingredients>
<Directions>Example Directions</Directions>
</HealthMisc>
</ProductType>
</Health>
</ProductData>
</Product>
</Message>
</AmazonEnvelope>`)
data := NewValues()
data.Set("PurgeAndReplace", strconv.FormatBool(false))
requestID, result, err := NewFeedService().SubmitFeed(TestCredential, []string{TestCredential.Region.MarketPlaceID}, "_POST_PRODUCT_DATA_", xmlBody, data)
if err != nil {
t.Errorf("SubmitFeed() error = %v", err)
return
}
if requestID == "" {
t.Errorf("SubmitFeed() requestID = %v", requestID)
}
if result == nil {
t.Errorf("SubmitFeed() result = %v", result)
}
t.Logf("result = %v", JsonMarshalIndentToString(result))
}
func TestFeedService_GetFeedSubmissionList(t *testing.T) {
data := NewValues()
data.Sets("FeedTypeList.Type", []string{"_POST_PRODUCT_DATA_"}...)
data.Sets("FeedSubmissionIdList.Id", []string{"85984018455"}...)
requestID, result, err := NewFeedService().GetFeedSubmissionList(TestCredential, data)
if err != nil {
t.Errorf("GetFeedSubmissionList() error = %v", err)
return
}
if requestID == "" {
t.Errorf("GetFeedSubmissionList() requestID = %v", requestID)
}
if result == nil {
t.Errorf("GetFeedSubmissionList() result = %v", result)
}
t.Logf("result = %v", JsonMarshalIndentToString(result))
}
func TestFeedService_GetFeedSubmissionResult(t *testing.T) {
result, err := NewFeedService().GetFeedSubmissionResult(TestCredential, "85984018455")
if err != nil {
t.Errorf("GetFeedSubmissionResult() error = %v", err)
return
}
if result == nil {
t.Errorf("GetFeedSubmissionResult() result = %v", result)
}
t.Logf("result = %v", JsonMarshalIndentToString(result))
}
func TestFeedService_GetFeedSubmissionCount(t *testing.T) {
requestID, count, err := NewFeedService().GetFeedSubmissionCount(TestCredential)
if err != nil {
t.Errorf("GetFeedSubmissionCount() error = %v", err)
return
}
if requestID == "" {
t.Errorf("GetFeedSubmissionCount() requestID = %v", requestID)
}
t.Logf("count = %v", count)
}