| 351 | } |
| 352 | |
| 353 | static 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 | |
| 403 | static int test_column_ops(cachedb_funcs *api, cachedb_con *con1, |
| 404 | cachedb_con *con2, const char *cachedb_name) |
no test coverage detected