From d9ac6d1a85f5032d85484bea7bf34a02399cd94f Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Mon, 16 Mar 2026 22:00:25 -0500 Subject: [PATCH] add good tests for sip processors --- .../test/sip-response-audio-create_test.go | 33 ++++++++++++++++++- .../test/sip-response-dtmf-create_test.go | 31 ++++++++++++++++- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/internal/processor/test/sip-response-audio-create_test.go b/internal/processor/test/sip-response-audio-create_test.go index f7ace06..c1de01b 100644 --- a/internal/processor/test/sip-response-audio-create_test.go +++ b/internal/processor/test/sip-response-audio-create_test.go @@ -40,7 +40,38 @@ func TestGoodSipResponseAudioCreate(t *testing.T) { params map[string]any payload any expected any - }{} + }{ + { + name: "basic", + params: map[string]any{ + "preWait": 0, + "audioFile": "good.wav", + "postWait": 0, + }, + payload: nil, + expected: processor.SipAudioFileResponse{ + PreWait: 0, + PostWait: 0, + AudioFile: "good.wav", + }, + }, + { + name: "template audio file", + params: map[string]any{ + "preWait": 1, + "audioFile": "{{.Payload.SomeField}}.wav", + "postWait": 2, + }, + payload: map[string]any{ + "SomeField": "templated", + }, + expected: processor.SipAudioFileResponse{ + PreWait: 1, + PostWait: 2, + AudioFile: "templated.wav", + }, + }, + } for _, test := range tests { t.Run(test.name, func(t *testing.T) { diff --git a/internal/processor/test/sip-response-dtmf-create_test.go b/internal/processor/test/sip-response-dtmf-create_test.go index d10852f..dd437b6 100644 --- a/internal/processor/test/sip-response-dtmf-create_test.go +++ b/internal/processor/test/sip-response-dtmf-create_test.go @@ -40,7 +40,36 @@ func TestGoodSipResponseDTMFCreate(t *testing.T) { params map[string]any payload any expected any - }{} + }{ + { + name: "basic", + params: map[string]any{ + "preWait": 0, + "digits": "12345", + "postWait": 0, + }, + payload: nil, + expected: processor.SipDTMFResponse{ + PreWait: 0, + PostWait: 0, + Digits: "12345", + }, + }, + { + name: "template digits", + params: map[string]any{ + "preWait": 0, + "digits": "{{.Payload}}", + "postWait": 0, + }, + payload: "67890", + expected: processor.SipDTMFResponse{ + PreWait: 0, + PostWait: 0, + Digits: "67890", + }, + }, + } for _, test := range tests { t.Run(test.name, func(t *testing.T) {