From 0cb72f63e706f9d769d5e91bf38537bf4ced3f30 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Fri, 5 Apr 2013 09:13:40 +0200 Subject: [PATCH] Return empty table instead of error if load is called with empty params --- ngcp/dp.lua | 4 ++-- ngcp/up.lua | 4 ++-- tests/ngcp_dp.lua | 4 ++-- tests/ngcp_pp.lua | 4 ++-- tests/ngcp_up.lua | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ngcp/dp.lua b/ngcp/dp.lua index 7505eb3..28e71e0 100644 --- a/ngcp/dp.lua +++ b/ngcp/dp.lua @@ -18,14 +18,14 @@ NGCPDomainPrefs_MT = { __index = NGCPDomainPrefs } function NGCPDomainPrefs:caller_load(uuid) if not uuid then - error("uuid is empty") + return {} end return NGCPDomainPrefs._load(self,"caller",uuid) end function NGCPDomainPrefs:callee_load(uuid) if not uuid then - error("uuid is empty") + return {} end return NGCPDomainPrefs._load(self,"callee",uuid) end diff --git a/ngcp/up.lua b/ngcp/up.lua index 91d4927..9159ab2 100644 --- a/ngcp/up.lua +++ b/ngcp/up.lua @@ -18,14 +18,14 @@ NGCPUserPrefs_MT = { __index = NGCPUserPrefs } function NGCPUserPrefs:caller_load(uuid) if not uuid then - error("uuid is empty") + return {} end return NGCPUserPrefs._load(self,"caller",uuid) end function NGCPUserPrefs:callee_load(uuid) if not uuid then - error("uuid is empty") + return {} end return NGCPUserPrefs._load(self,"callee",uuid) end diff --git a/tests/ngcp_dp.lua b/tests/ngcp_dp.lua index 80a0c4a..7814c4a 100644 --- a/tests/ngcp_dp.lua +++ b/tests/ngcp_dp.lua @@ -72,12 +72,12 @@ TestNGCPDomainPrefs = {} --class function TestNGCPDomainPrefs:test_caller_load_empty() assertTrue(self.d.config) - assertError(self.d.caller_load, nil) + assertEquals(self.d:caller_load(), {}) end function TestNGCPDomainPrefs:test_callee_load_empty() assertTrue(self.d.config) - assertError(self.d.callee_load, nil) + assertEquals(self.d:callee_load(), {}) end function TestNGCPDomainPrefs:test_caller_load() diff --git a/tests/ngcp_pp.lua b/tests/ngcp_pp.lua index 5e604e3..044dee2 100644 --- a/tests/ngcp_pp.lua +++ b/tests/ngcp_pp.lua @@ -72,12 +72,12 @@ TestNGCPPeerPrefs = {} --class function TestNGCPPeerPrefs:test_caller_load_empty() assertTrue(self.d.config) - assertEquals(self.d.caller_load(), nil) + assertEquals(self.d:caller_load(), {}) end function TestNGCPPeerPrefs:test_callee_load_empty() assertTrue(self.d.config) - assertEquals(self.d.callee_load(), nil) + assertEquals(self.d:callee_load(), {}) end function TestNGCPPeerPrefs:test_caller_load() diff --git a/tests/ngcp_up.lua b/tests/ngcp_up.lua index 767546f..1660179 100644 --- a/tests/ngcp_up.lua +++ b/tests/ngcp_up.lua @@ -67,12 +67,12 @@ TestNGCPUserPrefs = {} --class function TestNGCPUserPrefs:test_caller_load_empty() assertTrue(self.d.config) - assertError(self.d.caller_load, nil) + assertEquals(self.d:caller_load(), {}) end function TestNGCPUserPrefs:test_callee_load_empty() assertTrue(self.d.config) - assertError(self.d.callee_load, nil) + assertEquals(self.d:callee_load(), {}) end function TestNGCPUserPrefs:test_init()