4e91617e4d80f362d1db0dd0e8d5a676dad68cb6
1 #include "test/lib/common.hpp"
2 #include "test/lib/Shell.hpp"
3 #include "test/lib/Server.hpp"
4 #include "test/lib/Retry.hpp"
5 #include "test/lib/ReturnMatcher.hpp"
7 using Catch::Matchers::Contains
;
9 TEST_CASE("bin/memcat") {
10 Shell sh
{string
{TESTING_ROOT
"/../src/bin"}};
12 SECTION("no servers provided") {
14 REQUIRE_FALSE(sh
.run("memcat", output
));
15 REQUIRE(output
== "No servers provided\n");
20 REQUIRE(sh
.run("memcat --help", output
));
21 REQUIRE_THAT(output
, Contains("memcat"));
22 REQUIRE_THAT(output
, Contains("v1"));
23 REQUIRE_THAT(output
, Contains("help"));
24 REQUIRE_THAT(output
, Contains("version"));
25 REQUIRE_THAT(output
, Contains("option"));
26 REQUIRE_THAT(output
, Contains("--"));
27 REQUIRE_THAT(output
, Contains("="));
30 SECTION("with server") {
31 Server server
{MEMCACHED_BINARY
, {"-p", random_port_string
}};
33 LoneReturnMatcher test
{*memc
};
35 REQUIRE(server
.ensureListening());
36 auto port
= get
<int>(server
.getSocketOrPort());
37 auto comm
= "memcat --servers=localhost:" + to_string(port
) + " ";
39 REQUIRE_SUCCESS(memcached_server_add(*memc
, "localhost", port
));
42 REQUIRE_SUCCESS(memcached_set(*memc
, S("memcat"), S("MEMCAT-SET"), 0, 0));
45 REQUIRE(sh
.run(comm
+ "memcat", output
));
46 REQUIRE(output
== "MEMCAT-SET\n");
49 SECTION("not found") {
50 memcached_delete(*memc
, S("memcat"), 0);
53 REQUIRE_FALSE(sh
.run(comm
+ "memcat", output
));
54 REQUIRE_THAT(output
, !Contains("MEMCAT-SET"));
55 REQUIRE_THAT(output
, Contains("NOT FOUND"));