|
@@ -2452,6 +2452,199 @@ TEST(testNotifications, Negative) {
|
|
|
EXPECT_TRUE(cm.isLoggedIn());
|
|
|
}
|
|
|
|
|
|
+/* =====================================
|
|
|
+ * tests for queue and dequeue
|
|
|
+ */
|
|
|
+TEST(testQueue, TooFewArgs) {
|
|
|
+ FileManMock fm;
|
|
|
+ CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
+ cm.initLoggedIn();
|
|
|
+
|
|
|
+ std::string cmd;
|
|
|
+ std::vector<std::string> args;
|
|
|
+ CmdMan::CmdRet retvalCmd;
|
|
|
+
|
|
|
+ // prepare cmd/args
|
|
|
+ cmd = "queue";
|
|
|
+ args = {};
|
|
|
+
|
|
|
+ // stick into cmdman
|
|
|
+ retvalCmd = cm.execute(cmd, args);
|
|
|
+
|
|
|
+ // check things
|
|
|
+ EXPECT_EQ(retvalCmd.type, CmdMan::error);
|
|
|
+ EXPECT_EQ(retvalCmd.msg["command"].asString(), "queue");
|
|
|
+ EXPECT_FALSE(retvalCmd.msg["accept"].asBool());
|
|
|
+ EXPECT_NE(retvalCmd.msg["error"].asString(), "");
|
|
|
+
|
|
|
+ EXPECT_TRUE(cm.isLoggedIn());
|
|
|
+}
|
|
|
+
|
|
|
+TEST(testQueue, Positive) {
|
|
|
+ FileManMock fm;
|
|
|
+ CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
+ cm.initLoggedIn();
|
|
|
+
|
|
|
+ std::string cmd;
|
|
|
+ std::vector<std::string> args;
|
|
|
+ Json::Value root;
|
|
|
+ CmdMan::CmdRet retvalCmd;
|
|
|
+ CmdMan::CmdRet retvalHdl;
|
|
|
+
|
|
|
+ // prepare cmd/args/root
|
|
|
+ cmd = "queue";
|
|
|
+ args = {"fancy_file.txt"};
|
|
|
+ root["command"] = "queue";
|
|
|
+ root["file"] = "fancy_file.txt";
|
|
|
+ root["accept"] = true;
|
|
|
+
|
|
|
+ // stick into cmdman
|
|
|
+ retvalCmd = cm.execute(cmd, args);
|
|
|
+ retvalHdl = cm.handle(root);
|
|
|
+
|
|
|
+ // check things
|
|
|
+ EXPECT_EQ(retvalCmd.type, CmdMan::send);
|
|
|
+ EXPECT_EQ(retvalCmd.msg["command"].asString(), "queue");
|
|
|
+ EXPECT_EQ(retvalCmd.msg["file"].asString(), "fancy_file.txt");
|
|
|
+ EXPECT_EQ(retvalHdl.type, CmdMan::print);
|
|
|
+ EXPECT_EQ(retvalHdl.msg["command"].asString(), "queue");
|
|
|
+ EXPECT_TRUE(retvalHdl.msg["accept"].asBool());
|
|
|
+ EXPECT_EQ(retvalHdl.msg["file"].asString(), "fancy_file.txt");
|
|
|
+
|
|
|
+ EXPECT_TRUE(cm.isLoggedIn());
|
|
|
+}
|
|
|
+
|
|
|
+TEST(testQueue, Negative) {
|
|
|
+ FileManMock fm;
|
|
|
+ CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
+ cm.initLoggedIn();
|
|
|
+
|
|
|
+ std::string cmd;
|
|
|
+ std::vector<std::string> args;
|
|
|
+ Json::Value root;
|
|
|
+ CmdMan::CmdRet retvalCmd;
|
|
|
+ CmdMan::CmdRet retvalHdl;
|
|
|
+
|
|
|
+ // prepare cmd/args/root
|
|
|
+ cmd = "queue";
|
|
|
+ args = {"fancy_file.txt"};
|
|
|
+ root["command"] = "queue";
|
|
|
+ root["file"] = "fancy_file.txt";
|
|
|
+ root["accept"] = false;
|
|
|
+ root["error"] = "file does not exist";
|
|
|
+
|
|
|
+ // stick into cmdman
|
|
|
+ retvalCmd = cm.execute(cmd, args);
|
|
|
+ retvalHdl = cm.handle(root);
|
|
|
+
|
|
|
+ // check things
|
|
|
+ EXPECT_EQ(retvalCmd.type, CmdMan::send);
|
|
|
+ EXPECT_EQ(retvalCmd.msg["command"].asString(), "queue");
|
|
|
+ EXPECT_EQ(retvalCmd.msg["file"].asString(), "fancy_file.txt");
|
|
|
+ EXPECT_EQ(retvalHdl.type, CmdMan::error);
|
|
|
+ EXPECT_EQ(retvalHdl.msg["command"].asString(), "queue");
|
|
|
+ EXPECT_FALSE(retvalHdl.msg["accept"].asBool());
|
|
|
+ EXPECT_EQ(retvalHdl.msg["file"].asString(), "fancy_file.txt");
|
|
|
+ EXPECT_THAT(retvalHdl.msg["error"].asString(), testing::HasSubstr("file does not exist"));
|
|
|
+
|
|
|
+ EXPECT_TRUE(cm.isLoggedIn());
|
|
|
+}
|
|
|
+
|
|
|
+TEST(testDequeue, TooFewArgs) {
|
|
|
+ FileManMock fm;
|
|
|
+ CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
+ cm.initLoggedIn();
|
|
|
+
|
|
|
+ std::string cmd;
|
|
|
+ std::vector<std::string> args;
|
|
|
+ CmdMan::CmdRet retvalCmd;
|
|
|
+
|
|
|
+ // prepare cmd/args
|
|
|
+ cmd = "dequeue";
|
|
|
+ args = {};
|
|
|
+
|
|
|
+ // stick into cmdman
|
|
|
+ retvalCmd = cm.execute(cmd, args);
|
|
|
+
|
|
|
+ // check things
|
|
|
+ EXPECT_EQ(retvalCmd.type, CmdMan::error);
|
|
|
+ EXPECT_EQ(retvalCmd.msg["command"].asString(), "dequeue");
|
|
|
+ EXPECT_FALSE(retvalCmd.msg["accept"].asBool());
|
|
|
+ EXPECT_NE(retvalCmd.msg["error"].asString(), "");
|
|
|
+
|
|
|
+ EXPECT_TRUE(cm.isLoggedIn());
|
|
|
+}
|
|
|
+
|
|
|
+TEST(testDequeue, Positive) {
|
|
|
+ FileManMock fm;
|
|
|
+ CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
+ cm.initLoggedIn();
|
|
|
+
|
|
|
+ std::string cmd;
|
|
|
+ std::vector<std::string> args;
|
|
|
+ Json::Value root;
|
|
|
+ CmdMan::CmdRet retvalCmd;
|
|
|
+ CmdMan::CmdRet retvalHdl;
|
|
|
+
|
|
|
+ // prepare cmd/args/root
|
|
|
+ cmd = "dequeue";
|
|
|
+ args = {"fancy_file.txt"};
|
|
|
+ root["command"] = "dequeue";
|
|
|
+ root["file"] = "fancy_file.txt";
|
|
|
+ root["accept"] = true;
|
|
|
+
|
|
|
+ // stick into cmdman
|
|
|
+ retvalCmd = cm.execute(cmd, args);
|
|
|
+ retvalHdl = cm.handle(root);
|
|
|
+
|
|
|
+ // check things
|
|
|
+ EXPECT_EQ(retvalCmd.type, CmdMan::send);
|
|
|
+ EXPECT_EQ(retvalCmd.msg["command"].asString(), "dequeue");
|
|
|
+ EXPECT_EQ(retvalCmd.msg["file"].asString(), "fancy_file.txt");
|
|
|
+ EXPECT_EQ(retvalHdl.type, CmdMan::print);
|
|
|
+ EXPECT_EQ(retvalHdl.msg["command"].asString(), "dequeue");
|
|
|
+ EXPECT_TRUE(retvalHdl.msg["accept"].asBool());
|
|
|
+ EXPECT_EQ(retvalHdl.msg["file"].asString(), "fancy_file.txt");
|
|
|
+
|
|
|
+ EXPECT_TRUE(cm.isLoggedIn());
|
|
|
+}
|
|
|
+
|
|
|
+TEST(testDequeue, Negative) {
|
|
|
+ FileManMock fm;
|
|
|
+ CmdManForTest cm(fm, dummyDebugPrint);
|
|
|
+ cm.initLoggedIn();
|
|
|
+
|
|
|
+ std::string cmd;
|
|
|
+ std::vector<std::string> args;
|
|
|
+ Json::Value root;
|
|
|
+ CmdMan::CmdRet retvalCmd;
|
|
|
+ CmdMan::CmdRet retvalHdl;
|
|
|
+
|
|
|
+ // prepare cmd/args/root
|
|
|
+ cmd = "dequeue";
|
|
|
+ args = {"fancy_file.txt"};
|
|
|
+ root["command"] = "dequeue";
|
|
|
+ root["file"] = "fancy_file.txt";
|
|
|
+ root["accept"] = false;
|
|
|
+ root["error"] = "file not in queue";
|
|
|
+
|
|
|
+ // stick into cmdman
|
|
|
+ retvalCmd = cm.execute(cmd, args);
|
|
|
+ retvalHdl = cm.handle(root);
|
|
|
+
|
|
|
+ // check things
|
|
|
+ EXPECT_EQ(retvalCmd.type, CmdMan::send);
|
|
|
+ EXPECT_EQ(retvalCmd.msg["command"].asString(), "dequeue");
|
|
|
+ EXPECT_EQ(retvalCmd.msg["file"].asString(), "fancy_file.txt");
|
|
|
+ EXPECT_EQ(retvalHdl.type, CmdMan::error);
|
|
|
+ EXPECT_EQ(retvalHdl.msg["command"].asString(), "dequeue");
|
|
|
+ EXPECT_FALSE(retvalHdl.msg["accept"].asBool());
|
|
|
+ EXPECT_EQ(retvalHdl.msg["file"].asString(), "fancy_file.txt");
|
|
|
+ EXPECT_THAT(retvalHdl.msg["error"].asString(), testing::HasSubstr("file not in queue"));
|
|
|
+
|
|
|
+ EXPECT_TRUE(cm.isLoggedIn());
|
|
|
+}
|
|
|
+
|
|
|
/* =====================================
|
|
|
* test for all commands that require a login
|
|
|
*/
|