mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-26 21:05:30 +00:00
add tests for sip processors
This commit is contained in:
@@ -77,7 +77,77 @@ func TestBadSipResponseAudioCreate(t *testing.T) {
|
||||
params map[string]any
|
||||
payload any
|
||||
errorString string
|
||||
}{}
|
||||
}{
|
||||
{
|
||||
name: "missing preWait param",
|
||||
params: map[string]any{
|
||||
"audioFile": "good.wav",
|
||||
"postWait": 0,
|
||||
},
|
||||
errorString: "sip.response.audio.create preWait error: not found",
|
||||
},
|
||||
{
|
||||
name: "non-numeric preWait param",
|
||||
params: map[string]any{
|
||||
"preWait": "not a number",
|
||||
"audioFile": "good.wav",
|
||||
"postWait": 0,
|
||||
},
|
||||
errorString: "sip.response.audio.create preWait error: not a number",
|
||||
},
|
||||
{
|
||||
name: "missing audioFile param",
|
||||
params: map[string]any{
|
||||
"preWait": 0,
|
||||
"postWait": 0,
|
||||
},
|
||||
errorString: "sip.response.audio.create audioFile error: not found",
|
||||
},
|
||||
{
|
||||
name: "non-string audioFile param",
|
||||
params: map[string]any{
|
||||
"preWait": 0,
|
||||
"audioFile": 123,
|
||||
"postWait": 0,
|
||||
},
|
||||
errorString: "sip.response.audio.create audioFile error: not a string",
|
||||
},
|
||||
{
|
||||
name: "audioFile template syntax error",
|
||||
params: map[string]any{
|
||||
"preWait": 0,
|
||||
"audioFile": "{{.Unclosed",
|
||||
"postWait": 0,
|
||||
},
|
||||
errorString: "template: audioFile:1: unclosed action",
|
||||
},
|
||||
{
|
||||
name: "audioFile template error",
|
||||
params: map[string]any{
|
||||
"preWait": 0,
|
||||
"audioFile": "{{.NonExistentField}} ",
|
||||
"postWait": 0,
|
||||
},
|
||||
errorString: "template: audioFile:1:2: executing \"audioFile\" at <.NonExistentField>: can't evaluate field NonExistentField in type common.WrappedPayload",
|
||||
},
|
||||
{
|
||||
name: "missing postWait param",
|
||||
params: map[string]any{
|
||||
"preWait": 0,
|
||||
"audioFile": "good.wav",
|
||||
},
|
||||
errorString: "sip.response.audio.create postWait error: not found",
|
||||
},
|
||||
{
|
||||
name: "non-numeric postWait param",
|
||||
params: map[string]any{
|
||||
"preWait": 0,
|
||||
"audioFile": "good.wav",
|
||||
"postWait": "not a number",
|
||||
},
|
||||
errorString: "sip.response.audio.create postWait error: not a number",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
@@ -77,7 +77,87 @@ func TestBadSipResponseDTMFCreate(t *testing.T) {
|
||||
params map[string]any
|
||||
payload any
|
||||
errorString string
|
||||
}{}
|
||||
}{
|
||||
{
|
||||
name: "missing preWait param",
|
||||
params: map[string]any{
|
||||
"digits": "good.wav",
|
||||
"postWait": 0,
|
||||
},
|
||||
errorString: "sip.response.dtmf.create preWait error: not found",
|
||||
},
|
||||
{
|
||||
name: "non-numeric preWait param",
|
||||
params: map[string]any{
|
||||
"preWait": "not a number",
|
||||
"digits": "good.wav",
|
||||
"postWait": 0,
|
||||
},
|
||||
errorString: "sip.response.dtmf.create preWait error: not a number",
|
||||
},
|
||||
{
|
||||
name: "missing digits param",
|
||||
params: map[string]any{
|
||||
"preWait": 0,
|
||||
"postWait": 0,
|
||||
},
|
||||
errorString: "sip.response.dtmf.create digits error: not found",
|
||||
},
|
||||
{
|
||||
name: "non-string digits param",
|
||||
params: map[string]any{
|
||||
"preWait": 0,
|
||||
"digits": 12345,
|
||||
"postWait": 0,
|
||||
},
|
||||
errorString: "sip.response.dtmf.create digits error: not a string",
|
||||
},
|
||||
{
|
||||
name: "digits template syntax error",
|
||||
params: map[string]any{
|
||||
"preWait": 0,
|
||||
"digits": "{{.Unclosed",
|
||||
"postWait": 0,
|
||||
},
|
||||
errorString: "template: digits:1: unclosed action",
|
||||
},
|
||||
{
|
||||
name: "digits template error",
|
||||
params: map[string]any{
|
||||
"preWait": 0,
|
||||
"digits": "{{.NonExistentField}} ",
|
||||
"postWait": 0,
|
||||
},
|
||||
errorString: "template: digits:1:2: executing \"digits\" at <.NonExistentField>: can't evaluate field NonExistentField in type common.WrappedPayload",
|
||||
},
|
||||
{
|
||||
name: "invalid digits template result",
|
||||
payload: "nhf",
|
||||
params: map[string]any{
|
||||
"preWait": 0,
|
||||
"digits": "{{.Payload}}",
|
||||
"postWait": 0,
|
||||
},
|
||||
errorString: "sip.response.dtmf.create result of digits template contains invalid characters",
|
||||
},
|
||||
{
|
||||
name: "missing postWait param",
|
||||
params: map[string]any{
|
||||
"preWait": 0,
|
||||
"digits": "good.wav",
|
||||
},
|
||||
errorString: "sip.response.dtmf.create postWait error: not found",
|
||||
},
|
||||
{
|
||||
name: "non-numeric postWait param",
|
||||
params: map[string]any{
|
||||
"preWait": 0,
|
||||
"digits": "good.wav",
|
||||
"postWait": "not a number",
|
||||
},
|
||||
errorString: "sip.response.dtmf.create postWait error: not a number",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user