MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / test_query_unset

Function test_query_unset

cachedb/test/test_cachedb.c:353–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351}
352
353static int test_query_unset(cachedb_funcs *api, cachedb_con *con,
354 const cdb_dict_t *pairs, const char *cachedb_name)
355{
356 cdb_res_t res;
357 cdb_dict_t *dict1, *dict2;
358 cdb_pair_t *pair;
359 cdb_key_t key = CDB_KEY_INITIALIZER;
360
361 if (!strcmp(cachedb_name, "cassandra")) {
362 if (!ok(api->query(con, NULL, &res) == 0, "query: NULL filter"))
363 return 0;
364
365 ok(res.count == 0, "query: 0 results");
366
367 return 1;
368 }
369
370 if (!ok(api->query(con, NULL, &res) == 0, "query: NULL filter"))
371 return 0;
372
373 ok(res.count == 2, "query: 2 results");
374 dbg_cdb_dict("pairs: ", pairs);
375 dict1 = nth_dict(&res, 1);
376 dict2 = nth_dict(&res, 2);
377
378 dbg_cdb_dict("res 1: ", dict1);
379 dbg_cdb_dict("res 2: ", dict2);
380
381 init_str(&key.name, "key");
382
383 pair = cdb_dict_fetch(&key, dict1);
384 ok(!pair ||
385 (pair->val.type == CDB_DICT && cdb_dict_empty(&pair->val.val.dict)),
386 "subdict-1 is empty");
387
388 pair = cdb_dict_fetch(&key, dict2);
389 ok(!pair ||
390 (pair->val.type == CDB_DICT && cdb_dict_empty(&pair->val.val.dict)),
391 "subdict-2 is empty");
392
393 ok(nth_pair(dict1, 3) == NULL, "dict1 has 2 entries");
394 ok(nth_pair(dict2, 3) == NULL, "dict2 has 2 entries");
395
396 ok(!dict_cmp(dict1, dict2), "identical results");
397
398 cdb_free_rows(&res);
399
400 return 1;
401}
402
403static int test_column_ops(cachedb_funcs *api, cachedb_con *con1,
404 cachedb_con *con2, const char *cachedb_name)

Callers 1

test_column_opsFunction · 0.85

Calls 7

nth_dictFunction · 0.85
init_strFunction · 0.85
cdb_dict_fetchFunction · 0.85
cdb_dict_emptyFunction · 0.85
nth_pairFunction · 0.85
dict_cmpFunction · 0.85
cdb_free_rowsFunction · 0.85

Tested by

no test coverage detected