File size: 904 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
package harness

import (
	"github.com/target/goalert/devtools/mocktwilio"
)

type twilioAssertionVoiceCall struct {
	*twilioAssertionDevice
	*mocktwilio.VoiceCall
}

var _ ExpectedCall = &twilioAssertionVoiceCall{}

func (call *twilioAssertionVoiceCall) ThenExpect(keywords ...string) ExpectedCall {
	call.t.Helper()
	msg := call.Body()
	if !containsAllIgnoreCase(msg, keywords) {
		call.t.Fatalf("voice call message from %s was '%s'; expected keywords: %v", call.From(), msg, keywords)
	}

	return call
}
func (call *twilioAssertionVoiceCall) ThenPress(digits string) ExpectedCall {
	call.PressDigits(digits)
	return call
}
func (call *twilioAssertionVoiceCall) Hangup() {
	call.mx.Lock()
	defer call.mx.Unlock()
	call.VoiceCall.Hangup()

	for i, ac := range call.activeCalls {
		if ac == call.VoiceCall {
			call.activeCalls = append(call.activeCalls[:i], call.activeCalls[i+1:]...)
			break
		}
	}
}