Skip to content

Commit

Permalink
dialplan: Add test coverage for new variable functions.
Browse files Browse the repository at this point in the history
This change adds test coverage for the following new dialplan
functions:

GLOBAL_DELETE (deletes a global variable)
DELETE (delets a channel variable)
GLOBAL_EXISTS (checks whether a global variable is set or not)
VARIABLE_EXISTS (checks whether a channel variable is set or not)
  • Loading branch information
jcolp committed Sep 5, 2023
1 parent 37ca0d7 commit 1ec4435
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/pbx/dialplan/configs/ast1/extensions.conf
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ exten => start,1,NoOp()
same => n,ExecIf($[${TestCounter} = 12]?Goto(base64,start,1))
same => n,ExecIf($[${TestCounter} = 13]?Goto(aes,start,1))
same => n,ExecIf($[${TestCounter} = 14]?Goto(len,start,1))
same => n,ExecIf($[${TestCounter} = 31]?Goto(variable_deletion,start,1))

; GoSub testing
same => n,ExecIf($[${TestCounter} = 24]?Goto(gosubtest,start,1))
Expand Down Expand Up @@ -271,6 +272,31 @@ exten => start,1,NoOp()
same => n,GotoIf($[${Result} = Fail]?test,result_fail,1)
same => n,Goto(test,start,top)

; ------------------------------------------------------------------
; VARIABLE DELETION (GLOBAL_DELETE, DELETE)
; ------------------------------------------------------------------
[variable_deletion]
exten => start,1,NoOp()
same => n,Set(GLOBAL(alice)=exists)
same => n,Set(Result=${IF($["${GLOBAL_EXISTS(alice)}" = "1"]?OK:Fail)})
same => n,GotoIf($[${Result} = Fail]?test,result_fail,1)
same => n,Set(GLOBAL(alice)=)
same => n,Set(Result=${IF($["${GLOBAL_EXISTS(alice)}" = "1"]?OK:Fail)})
same => n,GotoIf($[${Result} = Fail]?test,result_fail,1)
same => n,Set(GLOBAL_DELETE(alice)=)
same => n,Set(Result=${IF($["${GLOBAL_EXISTS(alice)}" = "0"]?OK:Fail)})
same => n,GotoIf($[${Result} = Fail]?test,result_fail,1)
same => n,Set(bob=exists)
same => n,Set(Result=${IF($["${VARIABLE_EXISTS(bob)}" = "1"]?OK:Fail)})
same => n,GotoIf($[${Result} = Fail]?test,result_fail,1)
same => n,Set(bob=)
same => n,Set(Result=${IF($["${VARIABLE_EXISTS(bob)}" = "1"]?OK:Fail)})
same => n,GotoIf($[${Result} = Fail]?test,result_fail,1)
same => n,Set(DELETE(bob)=)
same => n,Set(Result=${IF($["${VARIABLE_EXISTS(bob)}" = "0"]?OK:Fail)})
same => n,GotoIf($[${Result} = Fail]?test,result_fail,1)
same => n,Goto(test,start,top)

; ------------------------------------------------------------------
; GoSub, Return, LOCAL, LOCAL_PEEK
; ------------------------------------------------------------------
Expand Down

0 comments on commit 1ec4435

Please sign in to comment.