update TODO
[awesomized/libmemcached] / test / tests / bin / memcapable.cpp
1 #include "test/lib/common.hpp"
2 #include "test/lib/Shell.hpp"
3 #include "test/lib/Server.hpp"
4
5 using Catch::Matchers::Contains;
6
7 TEST_CASE("bin/memcapable") {
8 Shell sh{string{TESTING_ROOT "/../src/bin"}};
9
10 SECTION("no servers provided") {
11 string output;
12 REQUIRE_FALSE(sh.run("memcapable", output));
13 REQUIRE(output == "No hostname was provided.\n");
14 }
15
16 SECTION("--help") {
17 string output;
18
19 REQUIRE(sh.run("memcapable --help", output));
20 REQUIRE_THAT(output, Contains("memcapable") && Contains("binary") && Contains("ascii"));
21 }
22
23 SECTION("with server") {
24 Server server{MEMCACHED_BINARY, {"-p", random_port_string}};
25
26 REQUIRE(server.ensureListening());
27
28 SECTION("ascii only") {
29 string output;
30 REQUIRE(sh.run("memcapable -a -h localhost -p " + to_string(get<int>(server.getSocketOrPort())), output));
31 REQUIRE_THAT(output, Contains("pass") && Contains("ascii"));
32 REQUIRE_THAT(output, !Contains("fail") && !Contains("binary"));
33 }
34 SECTION("binary only") {
35 string output;
36 REQUIRE(sh.run("memcapable -b -h localhost -p " + to_string(get<int>(server.getSocketOrPort())), output));
37 REQUIRE_THAT(output, Contains("pass") && Contains("binary"));
38 REQUIRE_THAT(output, !Contains("fail") && !Contains("ascii"));
39 }
40 SECTION("ascii and binary") {
41 string output;
42 REQUIRE(sh.run("memcapable -h localhost -p " + to_string(get<int>(server.getSocketOrPort())), output));
43 REQUIRE_THAT(output, Contains("pass") && Contains("ascii") && Contains("binary"));
44 REQUIRE_THAT(output, !Contains("fail"));
45 }
46
47 // fast exit
48 server.signal(SIGKILL);
49 }
50 }