Update January 17, 2025 (#141)
This commit is contained in:
		@@ -43,6 +43,7 @@ func TestListUnprocessedShipments(t *testing.T) {
 | 
			
		||||
					  "posting_number": "23713478-0018-3",
 | 
			
		||||
					  "order_id": 559293114,
 | 
			
		||||
					  "order_number": "33713378-0051",
 | 
			
		||||
					  "pickup_code_verified_at": "2025-01-17T11:03:00.124Z",
 | 
			
		||||
					  "status": "awaiting_packaging",
 | 
			
		||||
					  "delivery_method": {
 | 
			
		||||
						"id": 15110442724000,
 | 
			
		||||
@@ -238,6 +239,7 @@ func TestGetFBSShipmentsList(t *testing.T) {
 | 
			
		||||
					  "posting_number": "05708065-0029-1",
 | 
			
		||||
					  "order_id": 680420041,
 | 
			
		||||
					  "order_number": "05708065-0029",
 | 
			
		||||
					  "pickup_code_verified_at": "2025-01-17T10:59:26.614Z",
 | 
			
		||||
					  "status": "awaiting_deliver",
 | 
			
		||||
					  "substatus": "posting_awaiting_passport_data",
 | 
			
		||||
					  "delivery_method": {
 | 
			
		||||
@@ -301,7 +303,7 @@ func TestGetFBSShipmentsList(t *testing.T) {
 | 
			
		||||
				  ],
 | 
			
		||||
				  "has_next": true
 | 
			
		||||
				}
 | 
			
		||||
			}`,
 | 
			
		||||
				}`,
 | 
			
		||||
		},
 | 
			
		||||
		// Test No Client-Id or Api-Key
 | 
			
		||||
		{
 | 
			
		||||
@@ -591,8 +593,10 @@ func TestGetShipmentDataByIdentifier(t *testing.T) {
 | 
			
		||||
				  "posting_number": "57195475-0050-3",
 | 
			
		||||
				  "order_id": 438764970,
 | 
			
		||||
				  "order_number": "57195475-0050",
 | 
			
		||||
				  "pickup_code_verified_at": "2025-01-17T11:04:59.958Z",
 | 
			
		||||
				  "status": "awaiting_packaging",
 | 
			
		||||
				  "substatus": "posting_awaiting_passport_data",
 | 
			
		||||
				  "previous_substatus": "posting_transferring_to_delivery",
 | 
			
		||||
				  "delivery_method": {
 | 
			
		||||
					"id": 18114520187000,
 | 
			
		||||
					"name": "Ozon Логистика самостоятельно, Москва",
 | 
			
		||||
@@ -3371,3 +3375,54 @@ func TestDeleteShipment(t *testing.T) {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestVerifyCourierCode(t *testing.T) {
 | 
			
		||||
	t.Parallel()
 | 
			
		||||
 | 
			
		||||
	tests := []struct {
 | 
			
		||||
		statusCode int
 | 
			
		||||
		headers    map[string]string
 | 
			
		||||
		params     *VerifyCourierCodeParams
 | 
			
		||||
		response   string
 | 
			
		||||
	}{
 | 
			
		||||
		// Test Ok
 | 
			
		||||
		{
 | 
			
		||||
			http.StatusOK,
 | 
			
		||||
			map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
 | 
			
		||||
			&VerifyCourierCodeParams{
 | 
			
		||||
				PickupCode:    "string",
 | 
			
		||||
				PostingNumber: "string",
 | 
			
		||||
			},
 | 
			
		||||
			`{
 | 
			
		||||
				"valid": true
 | 
			
		||||
			}`,
 | 
			
		||||
		},
 | 
			
		||||
		// Test No Client-Id or Api-Key
 | 
			
		||||
		{
 | 
			
		||||
			http.StatusUnauthorized,
 | 
			
		||||
			map[string]string{},
 | 
			
		||||
			&VerifyCourierCodeParams{},
 | 
			
		||||
			`{
 | 
			
		||||
				"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))
 | 
			
		||||
 | 
			
		||||
		ctx, _ := context.WithTimeout(context.Background(), testTimeout)
 | 
			
		||||
		resp, err := c.FBS().VerifyCourierCode(ctx, test.params)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			t.Error(err)
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		compareJsonResponse(t, test.response, &VerifyCourierCodeResponse{})
 | 
			
		||||
 | 
			
		||||
		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