diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2019-03-30 17:03:42 +0700 |
---|---|---|
committer | Oliver Smith <osmith@sysmocom.de> | 2019-05-13 08:55:24 +0200 |
commit | c13599dc696fcab64219eba99afd0a2da9d0eec5 (patch) | |
tree | 9c8ac1ff6ecc794cc7dc0e82a71e2ca90738099e /tests | |
parent | 6b73fd9678b5b4570edc3722fda467a82b3c7ccb (diff) |
db_hlr.c: add db_subscr_exists_by_msisdn()
Check if a subscriber exists without generating an error log entry if
it does not. This is cheaper than db_subscr_get_by_msisdn(), as it
does not fetch the subscriber entry.
subscriber-create-on-demand will use this function to generate
a random unique MSISDN for new subscribers.
Related: OS#2542
Change-Id: Ibfbc408c966197682ba2b12d166ade4bfeb7abc2
Diffstat (limited to 'tests')
-rw-r--r-- | tests/db/db_test.c | 5 | ||||
-rw-r--r-- | tests/db/db_test.err | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/tests/db/db_test.c b/tests/db/db_test.c index 217a8c5..fdd62c5 100644 --- a/tests/db/db_test.c +++ b/tests/db/db_test.c @@ -294,6 +294,11 @@ static void test_subscr_create_update_sel_delete() ASSERT_SEL(imsi, imsi0, 0); ASSERT_SEL(msisdn, "5432101234567891", -ENOENT); + comment("Check if subscriber exists (by MSISDN)"); + + ASSERT_RC(db_subscr_exists_by_msisdn(dbc, "543210123456789"), 0); + ASSERT_RC(db_subscr_exists_by_msisdn(dbc, "5432101234567891"), -ENOENT); + comment("Set MSISDN on non-existent / invalid IMSI"); ASSERT_RC(db_subscr_update_msisdn_by_imsi(dbc, unknown_imsi, "99"), -ENOENT); diff --git a/tests/db/db_test.err b/tests/db/db_test.err index 0701089..4dc77e8 100644 --- a/tests/db/db_test.err +++ b/tests/db/db_test.err @@ -219,6 +219,13 @@ db_subscr_get_by_msisdn(dbc, "5432101234567891", &g_subscr) --> -ENOENT DAUC Cannot read subscriber from db: MSISDN='5432101234567891': No such subscriber +--- Check if subscriber exists (by MSISDN) + +db_subscr_exists_by_msisdn(dbc, "543210123456789") --> 0 + +db_subscr_exists_by_msisdn(dbc, "5432101234567891") --> -ENOENT + + --- Set MSISDN on non-existent / invalid IMSI db_subscr_update_msisdn_by_imsi(dbc, unknown_imsi, "99") --> -ENOENT |