MCPcopy Create free account
hub / github.com/Tencent/Tendis / testCommandArray

Function testCommandArray

src/tendisplus/commands/command_test.cpp:1934–1972  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1932*/
1933
1934void testCommandArray(std::shared_ptr<ServerEntry> svr,
1935 const std::vector<std::vector<std::string>>& arr,
1936 bool isError) {
1937 asio::io_context ioContext;
1938 asio::ip::tcp::socket socket(ioContext), socket1(ioContext);
1939 NetSession sess(svr, std::move(socket), 1, false, nullptr, nullptr);
1940
1941 for (auto& args : arr) {
1942 sess.setArgs(args);
1943
1944 // need precheck for args check, after exp.ok(), can execute runSessionCmd()
1945 // EXPECT_FALSE when !exp.ok()
1946 auto exp = Command::precheck(&sess);
1947 if (!exp.ok()) {
1948 std::stringstream ss;
1949 for (auto& str : args) {
1950 ss << str << " ";
1951 }
1952 LOG(INFO) << ss.str() << "ERROR:" << exp.status().toString();
1953 EXPECT_FALSE(exp.ok());
1954 continue;
1955 }
1956
1957 auto expect = Command::runSessionCmd(&sess);
1958 if (!expect.ok()) {
1959 std::stringstream ss;
1960 for (auto& str : args) {
1961 ss << str << " ";
1962 }
1963 LOG(INFO) << ss.str() << "ERROR:" << expect.status().toString();
1964 }
1965
1966 if (isError) {
1967 EXPECT_FALSE(expect.ok());
1968 } else {
1969 EXPECT_TRUE(expect.ok());
1970 }
1971 }
1972}
1973
1974void testCommandArrayResult(
1975 std::shared_ptr<ServerEntry> svr,

Callers 1

TESTFunction · 0.85

Calls 3

setArgsMethod · 0.45
okMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected