-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
resource_check_test.go
99 lines (95 loc) · 2.12 KB
/
resource_check_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
91
92
93
94
95
96
97
98
99
package main
import (
"net/http"
"testing"
"github.com/bitfield/checkly"
"github.com/google/go-cmp/cmp"
)
func TestEncodeDecodeResource(t *testing.T) {
want := testCheck("encode-decode-test")
res := resourceCheck()
data := res.TestResourceData()
resourceDataFromCheck(&want, data)
got, err := checkFromResourceData(data)
if err != nil {
t.Fatal(err)
}
if !cmp.Equal(want, got) {
t.Error(cmp.Diff(want, got))
}
}
func testCheck(name string) checkly.Check {
return checkly.Check{
Name: name,
Type: checkly.TypeAPI,
Frequency: 1,
Activated: true,
Muted: false,
ShouldFail: false,
Locations: []string{"eu-west-1"},
Script: "foo",
DegradedResponseTime: 15000,
MaxResponseTime: 30000,
EnvironmentVariables: []checkly.EnvironmentVariable{
{
Key: "ENVTEST",
Value: "Hello world",
},
},
DoubleCheck: false,
Tags: []string{
"foo",
"bar",
},
SSLCheck: true,
SSLCheckDomain: "example.com",
LocalSetupScript: "bogus",
LocalTearDownScript: "bogus",
AlertSettings: checkly.AlertSettings{
EscalationType: checkly.RunBased,
RunBasedEscalation: checkly.RunBasedEscalation{
FailedRunThreshold: 1,
},
TimeBasedEscalation: checkly.TimeBasedEscalation{
MinutesFailingThreshold: 5,
},
Reminders: checkly.Reminders{
Interval: 5,
},
SSLCertificates: checkly.SSLCertificates{
Enabled: false,
AlertThreshold: 3,
},
},
UseGlobalAlertSettings: false,
Request: checkly.Request{
Method: http.MethodGet,
URL: "http://example.com",
Headers: []checkly.KeyValue{
{
Key: "X-Test",
Value: "foo",
},
},
QueryParameters: []checkly.KeyValue{
{
Key: "query",
Value: "foo",
},
},
Assertions: []checkly.Assertion{
checkly.Assertion{
Source: checkly.StatusCode,
Comparison: checkly.Equals,
Target: "200",
},
},
Body: "",
BodyType: "NONE",
BasicAuth: checkly.BasicAuth{
Username: "example",
Password: "pass",
},
},
}
}