@@ -18,13 +18,31 @@ func TestContactPoints(t *testing.T) {
18
18
}
19
19
t .Log (pretty .PrettyFormat (ps ))
20
20
if len (ps ) != 2 {
21
- t .Errorf ("wrong number of contact points returned, got %#v " , ps )
21
+ t .Errorf ("wrong number of contact points returned, got %d " , len ( ps ) )
22
22
}
23
23
if ps [0 ].UID != "" {
24
- t .Errorf ("incorrect UID - expected %s on element %d, got %#v " , "" , 0 , ps )
24
+ t .Errorf ("incorrect UID - expected %s on element %d, got %s " , "" , 0 , ps [ 0 ]. UID )
25
25
}
26
26
if ps [1 ].UID != "rc5r0bjnz" {
27
- t .Errorf ("incorrect UID - expected %s on element %d, got %#v" , "rc5r0bjnz" , 0 , ps )
27
+ t .Errorf ("incorrect UID - expected %s on element %d, got %s" , "rc5r0bjnz" , 1 , ps [1 ].UID )
28
+ }
29
+ })
30
+
31
+ t .Run ("get contact points by name succeeds" , func (t * testing.T ) {
32
+ server , client := gapiTestTools (t , 200 , getContactPointsQueryJSON )
33
+ defer server .Close ()
34
+
35
+ ps , err := client .ContactPointsByName ("slack-receiver-1" )
36
+
37
+ if err != nil {
38
+ t .Error (err )
39
+ }
40
+ t .Log (pretty .PrettyFormat (ps ))
41
+ if len (ps ) != 1 {
42
+ t .Errorf ("wrong number of contact points returned, got %d" , len (ps ))
43
+ }
44
+ if ps [0 ].UID != "rc5r0bjnz" {
45
+ t .Errorf ("incorrect UID - expected %s on element %d, got %s" , "rc5r0bjnz" , 0 , ps [0 ].UID )
28
46
}
29
47
})
30
48
@@ -39,7 +57,7 @@ func TestContactPoints(t *testing.T) {
39
57
}
40
58
t .Log (pretty .PrettyFormat (p ))
41
59
if p .UID != "rc5r0bjnz" {
42
- t .Errorf ("incorrect UID - expected %s got %#v " , "rc5r0bjnz" , p )
60
+ t .Errorf ("incorrect UID - expected %s got %s " , "rc5r0bjnz" , p . UID )
43
61
}
44
62
})
45
63
@@ -132,6 +150,21 @@ const getContactPointsJSON = `
132
150
}
133
151
]`
134
152
153
+ const getContactPointsQueryJSON = `
154
+ [
155
+ {
156
+ "uid": "rc5r0bjnz",
157
+ "name": "slack-receiver-1",
158
+ "type": "slack",
159
+ "disableResolveMessage": false,
160
+ "settings": {
161
+ "recipient": "@foo",
162
+ "token": "[REDACTED]",
163
+ "url": "[REDACTED]"
164
+ }
165
+ }
166
+ ]`
167
+
135
168
const writeContactPointJSON = `
136
169
{
137
170
"uid": "rc5r0bjnz",
0 commit comments