Skip to content

Commit

Permalink
app_if: Add EndIf branching tests.
Browse files Browse the repository at this point in the history
Adds tests for the EndIf application
reflecting previously broken behavior.
  • Loading branch information
InterLinked1 authored and asterisk-org-access-app[bot] committed Jan 9, 2024
1 parent 90ec44a commit 09a501f
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 1 deletion.
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions tests/apps/if/if_endif/configs/ast1/extensions.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[default]
exten => s,1,Answer()
same => n,If(1)
same => n,NoOp(inside main if)
same => n,If(0)
same => n,NoOp()
same => n,EndIf()
same => n,NoOp(after nested false if)
same => n,If(1)
same => n,NoOp(inside true nested if)
same => n,EndIf()
same => n,NoOp(after nested true if)
; Test success: we exited only the inside If, not the outside If
same => n,UserEvent(IfSuccess,Result: Pass)
same => n,If(1)
same => n,NoOp(inside true nested if)
same => n,ExitIf()
same => n,EndIf()
; Test success: we exited only the inside If, not the outside If
same => n,UserEvent(IfSuccess,Result: Pass)
same => n,Hangup()
same => n,EndIf()
; Test failed: we shouldn't reach the exterior EndIf
same => n,UserEvent(IfSuccess,Result: Fail)
same => n,Assert(0)
same => n,NoOp(after main if)
same => n,Hangup()
59 changes: 59 additions & 0 deletions tests/apps/if/if_endif/test-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
testinfo:
summary: 'Ensure that EndIf branches correctly.'
description: |
'This tests the ElseIf application
to ensure branch behavior is correct (issue #341)'
test-modules:
test-object:
config-section: test-object-config
typename: 'test_case.TestCaseModule'
modules:
-
config-section: caller-originator
typename: 'pluggable_modules.Originator'
-
config-section: hangup-monitor
typename: 'pluggable_modules.HangupMonitor'
-
config-section: ami-config
typename: 'pluggable_modules.EventActionModule'

test-object-config:
connect-ami: True

caller-originator:
channel: 'Local/s@default'
context: 'nothing'
exten: '0'
priority: '1'
trigger: 'ami_connect'

hangup-monitor:
ids: '0'

ami-config:
-
ami-events:
conditions:
match:
Event: 'UserEvent'
UserEvent: 'IfSuccess'
requirements:
match:
Result: 'Pass'
count: 2
stop_test:

properties:
tags:
- dial
- apps
dependencies:
- python: 'twisted'
- python: 'starpy'
- asterisk: 'app_dial'
- asterisk: 'app_userevent'
- asterisk: 'app_originate'
- asterisk: 'app_if'
- asterisk: 'pbx_config'
3 changes: 3 additions & 0 deletions tests/apps/if/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tests:
- test: 'if_comprehensive'
- test: 'if_endif'
2 changes: 1 addition & 1 deletion tests/apps/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ tests:
- test: 'mf'
- test: 'sf'
- test: 'read'
- test: 'if'
- dir: 'if'
- test: 'signal'
- test: 'senddtmf'

0 comments on commit 09a501f

Please sign in to comment.