-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcustomeralert_test.go
90 lines (84 loc) · 2.6 KB
/
customeralert_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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package metronome_test
import (
"context"
"errors"
"os"
"testing"
"github.com/Metronome-Industries/metronome-go"
"github.com/Metronome-Industries/metronome-go/internal/testutil"
"github.com/Metronome-Industries/metronome-go/option"
)
func TestCustomerAlertGet(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := metronome.NewClient(
option.WithBaseURL(baseURL),
option.WithBearerToken("My Bearer Token"),
)
_, err := client.Customers.Alerts.Get(context.TODO(), metronome.CustomerAlertGetParams{
AlertID: metronome.F("8deed800-1b7a-495d-a207-6c52bac54dc9"),
CustomerID: metronome.F("9b85c1c1-5238-4f2a-a409-61412905e1e1"),
})
if err != nil {
var apierr *metronome.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}
func TestCustomerAlertListWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := metronome.NewClient(
option.WithBaseURL(baseURL),
option.WithBearerToken("My Bearer Token"),
)
_, err := client.Customers.Alerts.List(context.TODO(), metronome.CustomerAlertListParams{
CustomerID: metronome.F("9b85c1c1-5238-4f2a-a409-61412905e1e1"),
NextPage: metronome.F("next_page"),
AlertStatuses: metronome.F([]metronome.CustomerAlertListParamsAlertStatus{metronome.CustomerAlertListParamsAlertStatusEnabled}),
})
if err != nil {
var apierr *metronome.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}
func TestCustomerAlertReset(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := metronome.NewClient(
option.WithBaseURL(baseURL),
option.WithBearerToken("My Bearer Token"),
)
err := client.Customers.Alerts.Reset(context.TODO(), metronome.CustomerAlertResetParams{
AlertID: metronome.F("5e8691bf-b22a-4672-922d-f80eee940f01"),
CustomerID: metronome.F("4c83caf3-8af4-44e2-9aeb-e290531726d9"),
})
if err != nil {
var apierr *metronome.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}