@@ -18,13 +18,31 @@ func TestContactPoints(t *testing.T) {
1818 }
1919 t .Log (pretty .PrettyFormat (ps ))
2020 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 ) )
2222 }
2323 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 )
2525 }
2626 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 )
2846 }
2947 })
3048
@@ -39,7 +57,7 @@ func TestContactPoints(t *testing.T) {
3957 }
4058 t .Log (pretty .PrettyFormat (p ))
4159 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 )
4361 }
4462 })
4563
@@ -132,6 +150,21 @@ const getContactPointsJSON = `
132150 }
133151]`
134152
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+
135168const writeContactPointJSON = `
136169{
137170 "uid": "rc5r0bjnz",
0 commit comments