From: Michael Wallner Date: Tue, 17 Nov 2020 19:55:14 +0000 (+0100) Subject: bin: consolidate clients X-Git-Tag: 1.1.0-beta1~101 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=fc1ccb6416b81f3c62614805158f8ae1180471dd;p=awesomized%2Flibmemcached bin: consolidate clients --- diff --git a/src/bin/memtouch.cc b/src/bin/memtouch.cc index 400c47ef..24d3869f 100644 --- a/src/bin/memtouch.cc +++ b/src/bin/memtouch.cc @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) { opt.add(def); } - opt.add("expiration", 'e', no_argument, "Expiration time in seconds or unix timestamp."); + opt.add("expire", 'e', required_argument, "Expiration time in seconds or unix timestamp."); char **argp = nullptr; if (!opt.parse(argc, argv, &argp)) { diff --git a/test/tests/bin/memtouch.cpp b/test/tests/bin/memtouch.cpp index 35da7dc9..c142b8dc 100644 --- a/test/tests/bin/memtouch.cpp +++ b/test/tests/bin/memtouch.cpp @@ -12,19 +12,20 @@ TEST_CASE("bin/memtouch") { SECTION("no servers provided") { string output; REQUIRE_FALSE(sh.run("memtouch", output)); - REQUIRE(output == "No Servers provided\n"); + REQUIRE(output == "No servers provided.\n"); } SECTION("--help") { string output; REQUIRE(sh.run("memtouch --help", output)); - REQUIRE_THAT(output, Contains("memtouch")); - REQUIRE_THAT(output, Contains("v1")); - REQUIRE_THAT(output, Contains("help")); - REQUIRE_THAT(output, Contains("version")); - REQUIRE_THAT(output, Contains("option")); - REQUIRE_THAT(output, Contains("--")); - REQUIRE_THAT(output, Contains("=")); + REQUIRE_THAT(output, Contains("memtouch v1")); + REQUIRE_THAT(output, Contains("Usage:")); + REQUIRE_THAT(output, Contains("key [key ...]")); + REQUIRE_THAT(output, Contains("Options:")); + REQUIRE_THAT(output, Contains("-h|--help")); + REQUIRE_THAT(output, Contains("-V|--version")); + REQUIRE_THAT(output, Contains("Environment:")); + REQUIRE_THAT(output, Contains("MEMCACHED_SERVERS")); } SECTION("with server") { @@ -57,7 +58,10 @@ TEST_CASE("bin/memtouch") { SECTION("expires") { REQUIRE_SUCCESS(memcached_set(*memc, S("memtouch"), S("memtouch"), 60, 0)); REQUIRE_SUCCESS(memcached_exist(*memc, S("memtouch"))); - REQUIRE(sh.run(comm + "--expire=" + to_string(time(nullptr) - 2) + " memtouch")); + string output; + bool ok = sh.run(comm + " -v --expire=" + to_string(time(nullptr) - 2) + " memtouch", output); + REQUIRE(output == ""); + REQUIRE(ok); REQUIRE_RC(MEMCACHED_NOTFOUND, memcached_exist(*memc, S("memtouch"))); } }