update TODO
[awesomized/libmemcached] / test / tests / memcached / touch.cpp
1 #include "test/lib/common.hpp"
2 #include "test/lib/MemcachedCluster.hpp"
3
4 TEST_CASE("memcached_touch") {
5 auto test = MemcachedCluster::mixed();
6 auto memc = &test.memc;
7 memcached_return_t rc;
8 auto binary = GENERATE(0, 1);
9
10 test.enableBinaryProto(binary);
11
12 DYNAMIC_SECTION("touch binary=" << binary) {
13 REQUIRE_FALSE(memcached_get(memc, S(__func__), nullptr, nullptr, &rc));
14 REQUIRE_RC(MEMCACHED_NOTFOUND, rc);
15
16 REQUIRE_SUCCESS(memcached_set(memc, S(__func__), S(__func__), 2, 0));
17
18 Malloced val(memcached_get(memc, S(__func__), nullptr, nullptr, &rc));
19 REQUIRE_SUCCESS(rc);
20 REQUIRE(*val);
21
22 REQUIRE_SUCCESS(memcached_touch(memc, S(__func__), 60));
23 val = memcached_get(memc, S(__func__), nullptr, nullptr, &rc);
24 REQUIRE_SUCCESS(rc);
25 REQUIRE(*val);
26
27 REQUIRE_SUCCESS(memcached_touch(memc, S(__func__), time(nullptr) - 2));
28 val = memcached_get(memc, S(__func__), nullptr, nullptr, &rc);
29 REQUIRE_RC(MEMCACHED_NOTFOUND, rc);
30 REQUIRE_FALSE(*val);
31 }
32
33 DYNAMIC_SECTION("touch_by_key binary=" << binary) {
34 REQUIRE_RC(MEMCACHED_NOTFOUND, memcached_touch_by_key(memc, S(__func__), S(__func__), 60));
35 REQUIRE_SUCCESS(memcached_set_by_key(memc, S(__func__), S(__func__), S(__func__), 2, 0));
36
37 Malloced val(memcached_get_by_key(memc, S(__func__), S(__func__), nullptr, nullptr, &rc));
38 REQUIRE_SUCCESS(rc);
39 REQUIRE(*val);
40
41 REQUIRE_SUCCESS(memcached_touch_by_key(memc, S(__func__), S(__func__), time(nullptr) - 2));
42 val = memcached_get_by_key(memc, S(__func__), S(__func__), nullptr, nullptr, &rc);
43 REQUIRE_RC(MEMCACHED_NOTFOUND, rc);
44 REQUIRE_FALSE(*val);
45
46 REQUIRE_RC(MEMCACHED_NOTFOUND, memcached_touch_by_key(memc, S(__func__), S(__func__), 60));
47 }
48 }