forked from airheartdev/duffel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors_test.go
43 lines (38 loc) · 1023 Bytes
/
errors_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
package duffel
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/assert"
"gopkg.in/h2non/gock.v1"
)
func TestGatewayTimeoutError(t *testing.T) {
defer gock.Off()
a := assert.New(t)
gock.New("https://api.duffel.com").
Post("/air/partial_offer_requests").
Reply(504).
SetHeader("Ratelimit-Limit", "5").
SetHeader("Ratelimit-Remaining", "5").
SetHeader("Ratelimit-Reset", time.Now().Format(time.RFC1123)).
SetHeader("Date", time.Now().Format(time.RFC1123)).
File("fixtures/504-gateway-timeout.json")
ctx := context.TODO()
client := New("duffel_test_123")
_, err := client.CreatePartialOfferRequest(ctx, PartialOfferRequestInput{
Passengers: []OfferRequestPassenger{
{
Type: PassengerTypeAdult,
},
},
CabinClass: CabinClassEconomy,
Slices: []OfferRequestSlice{
{
DepartureDate: Date(time.Now().AddDate(0, 0, 7)),
Origin: "STN",
Destination: "LHR",
},
},
})
a.Equal(true, IsErrorCode(err, GatewayTimeout), "is 504 gateway timeout")
}