Skip to content

Commit 663eb61

Browse files
committed
fix: update new error response detail unit test
1 parent 0cfd831 commit 663eb61

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

unit_test.go

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,30 +134,37 @@ func TestTypeErrorResponseTwo(t *testing.T) {
134134
}
135135

136136
func TestTypeErrorResponseThree(t *testing.T) {
137+
137138
response := `{
138-
"name": "BUSINESS_ERROR",
139-
"debug_id": "[REDACTED]",
140-
"message": "Business error",
141-
"information_link": "https://developer.paypal.com/webapps/developer/docs/api/#BUSINESS_ERROR",
142-
"details": [
143-
{
144-
"name": "TOKEN_NOT_FOUND",
145-
"message": "Not Found: Invalid BA-Token Identifier"
146-
}
147-
]
148-
}`
139+
"name": "DUPLICATE_TRACKER",
140+
"message": "Business error",
141+
"debug_id": "[REDACTED]",
142+
"details": [
143+
{
144+
"field": "#/trackers/0/tracking_number",
145+
"value": "[TRACKING_NUMBER]",
146+
"location": "body",
147+
"issue": "TRACKING_NUMBER_ALREADY_EXIST",
148+
"description": "Tracking information already exists with same Tracking number",
149+
"links": [
150+
151+
]
152+
}
153+
]
154+
}`
149155

150156
i := &ErrorResponse{}
151157
err := json.Unmarshal([]byte(response), i)
152158
if err != nil {
153159
t.Errorf("ErrorResponse Unmarshal failed")
154160
}
155161

156-
if i.Name != "BUSINESS_ERROR" ||
162+
if i.Name != "DUPLICATE_TRACKER" ||
157163
i.Message != "Business error" ||
158164
len(i.Details) != 1 ||
159-
i.Details[0].Name != "TOKEN_NOT_FOUND" ||
160-
i.Details[0].Message != "Not Found: Invalid BA-Token Identifier" {
165+
i.Details[0].Issue != "TRACKING_NUMBER_ALREADY_EXIST" ||
166+
i.Details[0].Value != "[TRACKING_NUMBER]" ||
167+
i.Details[0].Description != "Tracking information already exists with same Tracking number" {
161168
t.Errorf("ErrorResponse decoded result is incorrect, Given: %v", i)
162169
}
163170
}

0 commit comments

Comments
 (0)