77 "testing"
88
99 "github.com/stretchr/testify/assert"
10- openapi "github.com/twilio/twilio-go/rest/api/v2010"
10+ ApiV2010 "github.com/twilio/twilio-go/rest/api/v2010"
11+ ChatV2 "github.com/twilio/twilio-go/rest/chat/v2"
12+ EventsV1 "github.com/twilio/twilio-go/rest/events/v1"
1113)
1214
1315var from string
@@ -24,7 +26,7 @@ func TestMain(m *testing.M) {
2426}
2527
2628func TestSendingAText (t * testing.T ) {
27- params := & openapi .CreateMessageParams {}
29+ params := & ApiV2010 .CreateMessageParams {}
2830 params .SetTo (to )
2931 params .SetFrom (from )
3032 params .SetBody ("Hello there" )
@@ -46,7 +48,7 @@ func TestListingNumbers(t *testing.T) {
4648}
4749
4850func TestListingANumber (t * testing.T ) {
49- params := & openapi .ListIncomingPhoneNumberParams {}
51+ params := & ApiV2010 .ListIncomingPhoneNumberParams {}
5052 params .SetPhoneNumber (from )
5153
5254 resp , err := testClient .ApiV2010 .ListIncomingPhoneNumber (params )
@@ -55,3 +57,61 @@ func TestListingANumber(t *testing.T) {
5557 assert .Equal (t , 1 , len (resp ))
5658 assert .Equal (t , from , * resp [0 ].PhoneNumber )
5759}
60+
61+ func TestSpecialCharacters (t * testing.T ) {
62+ serviceParams := & ChatV2.CreateServiceParams {}
63+ serviceParams .SetFriendlyName ("service|friendly&name" )
64+
65+ service , err := testClient .ChatV2 .CreateService (serviceParams )
66+ assert .Nil (t , err )
67+ assert .NotNil (t , service )
68+
69+ userParams := & ChatV2.CreateUserParams {}
70+ userParams .SetIdentity ("user|identity&string" )
71+
72+ user , err := testClient .ChatV2 .CreateUser (* service .Sid , userParams )
73+ assert .Nil (t , err )
74+ assert .NotNil (t , user )
75+
76+ err = testClient .ChatV2 .DeleteUser (* service .Sid , * user .Identity )
77+ assert .Nil (t , err )
78+ err = testClient .ChatV2 .DeleteService (* service .Sid )
79+ assert .Nil (t , err )
80+ }
81+
82+ func TestListParams (t * testing.T ) {
83+ sinkConfig := map [string ]interface {}{
84+ "destination" : "http://example.org/webhook" ,
85+ "method" : "post" ,
86+ "batch_events" : false ,
87+ }
88+ sinkParams := & EventsV1.CreateSinkParams {}
89+ sinkParams .SetSinkConfiguration (sinkConfig )
90+ sinkParams .SetDescription ("test sink" )
91+ sinkParams .SetSinkType ("webhook" )
92+ sink , err := testClient .EventsV1 .CreateSink (sinkParams )
93+ assert .Nil (t , err )
94+ assert .NotNil (t , sink )
95+
96+ types := []map [string ]interface {}{
97+ {
98+ "type" : "com.twilio.messaging.message.delivered" ,
99+ },
100+ {
101+ "type" : "com.twilio.messaging.message.sent" ,
102+ },
103+ }
104+ subscriptionsParams := & EventsV1.CreateSubscriptionParams {}
105+ subscriptionsParams .SetSinkSid (* sink .Sid )
106+ subscriptionsParams .SetTypes (types )
107+ subscriptionsParams .SetDescription ("test subscription" )
108+ subscription , err := testClient .EventsV1 .CreateSubscription (subscriptionsParams )
109+ assert .Nil (t , err )
110+ assert .NotNil (t , subscription )
111+
112+ // Clean up the resources we've created
113+ err = testClient .EventsV1 .DeleteSubscription (* subscription .Sid )
114+ assert .Nil (t , err )
115+ err = testClient .EventsV1 .DeleteSink (* sink .Sid )
116+ assert .Nil (t , err )
117+ }
0 commit comments