-
Notifications
You must be signed in to change notification settings - Fork 135
/
Copy pathconference_test.go
82 lines (68 loc) · 2.47 KB
/
conference_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
package gotwilio
import (
"os"
"testing"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)
var testConferenceSid = os.Getenv("TEST_CONFERENCE_SID")
var testPhoneNumberTo = os.Getenv("TEST_PHONE_NUMBER_TO")
var testPhoneNumberFrom = os.Getenv("TEST_PHONE_NUMBER_FROM")
func TestTwilio_GetConference(t *testing.T) {
log.SetLevel(log.DebugLevel)
client := initTestTwilioClient()
res, exception, err := client.GetConference(testConferenceSid)
validateTwilioException(t, exception)
assert.NoError(t, err)
assert.NotNil(t, res)
assert.Equal(t, testConferenceSid, res.Sid)
assert.NotEmpty(t, res.FriendlyName)
}
// Test Conference functionality end to end. Real Twilio Account SID and Auth Token are required.
// A real conference call must also be active.
func TestTwilio_Conference(t *testing.T) {
log.SetLevel(log.DebugLevel)
client := initTestTwilioClient()
// cannot create a new conference in code
conf, exception, err := client.GetConference(testConferenceSid)
validateTwilioException(t, exception)
assert.NoError(t, err)
assert.NotNil(t, conf)
assert.Equal(t, testConferenceSid, conf.Sid)
assert.NotEmpty(t, conf.FriendlyName)
// add participant to call
participant, exception, err := client.AddConferenceParticipant(conf.Sid, &ConferenceParticipantOptions{
From: testPhoneNumberFrom,
To: testPhoneNumberTo,
Timeout: 15,
Record: NewBoolean(false),
Muted: NewBoolean(false),
})
validateTwilioException(t, exception)
assert.NoError(t, err)
assert.NotNil(t, participant)
assert.NotEmpty(t, participant.CallSid)
// get same participant's data
participant2, exception, err := client.GetConferenceParticipant(conf.Sid, participant.CallSid)
validateTwilioException(t, exception)
assert.NoError(t, err)
assert.NotNil(t, participant2)
assert.Equal(t, participant.CallSid, participant2.CallSid)
// update the conference
_, exception, err = client.UpdateConference(conf.Sid, &ConferenceOptions{
AnnounceURL: "https://google.com",
AnnounceMethod: "GET",
})
validateTwilioException(t, exception)
assert.NoError(t, err)
// update the participant
_, exception, err = client.UpdateConferenceParticipant(conf.Sid, participant.CallSid, &ConferenceParticipantOptions{
Muted: NewBoolean(true),
})
validateTwilioException(t, exception)
assert.NoError(t, err)
// delete the participant
exception, err = client.DeleteConferenceParticipant(conf.Sid, participant.CallSid)
validateTwilioException(t, exception)
assert.NoError(t, err)
}