-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_handling_test.go
64 lines (48 loc) · 1.65 KB
/
error_handling_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
package seatsio
import (
"github.com/seatsio/seatsio-go/v9/events"
"github.com/seatsio/seatsio-go/v9/shared"
"github.com/seatsio/seatsio-go/v9/test_util"
"github.com/stretchr/testify/require"
"testing"
)
func Test300(t *testing.T) {
t.Parallel()
var event *events.Event
response, err := shared.ApiClient("someSecretKey", "https://httpbin.seatsio.net").
R().
Get("/status/300")
_, e := shared.AssertOk(response, err, &event)
require.EqualError(t, e, "server returned error 300. Body: ")
}
func Test301(t *testing.T) {
t.Parallel()
var event *events.Event
response, err := shared.ApiClient("someSecretKey", "https://httpbin.seatsio.net").
R().
Get("/status/301")
_, e := shared.AssertOk(response, err, &event)
require.NoError(t, e)
}
func Test400(t *testing.T) {
t.Parallel()
company := test_util.CreateTestCompany(t)
client := NewSeatsioClient(test_util.BaseUrl, company.Admin.SecretKey)
_, err := client.Events.Create(&events.CreateEventParams{ChartKey: "foo"})
require.ErrorContains(t, err, "Chart not found: foo was not found in workspace")
}
func Test500(t *testing.T) {
t.Parallel()
var event *events.Event
response, err := shared.ApiClient("someSecretKey", "https://httpbin.seatsio.net").
R().
Get("/status/500")
_, e := shared.AssertOk(response, err, &event)
require.EqualError(t, e, "server returned error 500. Body: ")
}
func TestWeirdError(t *testing.T) {
t.Parallel()
client := NewSeatsioClient("unknownProtocol://", "someSecretKey")
_, err := client.Events.Create(&events.CreateEventParams{ChartKey: "foo"})
require.EqualError(t, err, "Post \"unknownprotocol:/events\": unsupported protocol scheme \"unknownprotocol\"")
}