Pārlūkot izejas kodu

Resolve "CLI requests listdata when server has no files"

Sander, Paul 4 gadi atpakaļ
vecāks
revīzija
4c6ba26c6e
2 mainītis faili ar 10 papildinājumiem un 5 dzēšanām
  1. 5 0
      cli/src/cmdman.cpp
  2. 5 5
      cli/test/cmdman_test.cpp

+ 5 - 0
cli/src/cmdman.cpp

@@ -778,6 +778,11 @@ CmdMan::CmdRet CmdMan::handleList(Json::Value root) {
 		output["accept"] = false;
 		output["error"] = "Server reports: " + root["error"].asString();
 		fileman.cancelList();
+	} else if (root["items"].asInt() == 0) {
+		retval.type = print;
+		output["accept"] = false;
+		output["error"] = "There are no files stored on the server.";
+		fileman.closeList();
 	} else if (!fileman.isListing()) {
 		retval.type = error;
 		output["accept"] = false;

+ 5 - 5
cli/test/cmdman_test.cpp

@@ -1794,8 +1794,8 @@ TEST(testList, Negative_ListEmpty) {
 	cmd = "list";
 	args = {};
 	root["command"] = "list";
-	root["accept"] = false;
-	root["error"] = "no chunks to send";
+	root["accept"] = true;
+	root["items"] = 0;
 
 	// stick into cmdman and check things
 	EXPECT_CALL(fm, openList).WillOnce(testing::Return(true));
@@ -1804,13 +1804,13 @@ TEST(testList, Negative_ListEmpty) {
 	EXPECT_EQ(retvalCmd.type, CmdMan::send);
 	EXPECT_EQ(retvalCmd.msg["command"].asString(), "list");
 
-	EXPECT_CALL(fm, cancelList);
+	EXPECT_CALL(fm, closeList);
 	retvalHdl = cm.handle(root);
 
-	EXPECT_EQ(retvalHdl.type, CmdMan::error);
+	EXPECT_EQ(retvalHdl.type, CmdMan::print);
 	EXPECT_EQ(retvalHdl.msg["command"].asString(), "list");
 	EXPECT_FALSE(retvalHdl.msg["accept"].asBool());
-	EXPECT_THAT(retvalHdl.msg["error"].asString(), testing::HasSubstr("no chunks to send"));
+	EXPECT_THAT(retvalHdl.msg["error"].asString(), testing::HasSubstr("There are no files stored on the server."));
 
 	EXPECT_TRUE(cm.isLoggedIn());
 }