From da71d4422764b98d7d729458c97f98ffa0426c31 Mon Sep 17 00:00:00 2001 From: Andrew Pogrebennyk Date: Wed, 3 Feb 2016 10:07:01 +0100 Subject: [PATCH] MT#17709 remove only 1st occurrence of the key from the call-id list The count argument influences the operation in the following ways: * count > 0: Remove elements equal to value moving from head to tail. * count < 0: Remove elements equal to value moving from tail to head. * count = 0: Remove all elements equal to value. Change-Id: Ia77b760fcada0027fe58a48f4b335d5c264e8917 --- ngcp/dlgcnt.lua | 2 +- tests/ngcp_dlgcnt.lua | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ngcp/dlgcnt.lua b/ngcp/dlgcnt.lua index dee824d..1be1988 100644 --- a/ngcp/dlgcnt.lua +++ b/ngcp/dlgcnt.lua @@ -131,7 +131,7 @@ end if not self._test_connection(self.pair) then self.pair = self._connect(self.config.pair); end - local num = self.pair:lrem(callid, 0, key); + local num = self.pair:lrem(callid, 1, key); sr.log("dbg", string.format("pair:lrem[%s]=>[%s] %d\n", callid, key, num)); if not self._test_connection(self.central) then self.central = self._connect(self.config.central); diff --git a/tests/ngcp_dlgcnt.lua b/tests/ngcp_dlgcnt.lua index 611b52a..38cf581 100644 --- a/tests/ngcp_dlgcnt.lua +++ b/tests/ngcp_dlgcnt.lua @@ -230,5 +230,20 @@ TestNGCPDlgCnt = {} --class assertTrue(res) end + function TestNGCPDlgCnt:test_del_key() + self.pair:ping() ;mc :returns(true) + self.pair:lrem("callid0", 1, "key1") ;mc :returns(1) + + self.central:ping() ;mc :returns(true) + self.central:decr("key1") ;mc :returns(1) + + mc:replay() + self.dlg:del_key("callid0", "key1") + mc:verify() + + assertIs(self.dlg.central, self.central) + assertIs(self.dlg.pair, self.pair) + end + -- class TestNGCPDlgCnt --EOF