Skip to content

Commit

Permalink
Fix return code for getrelay channel request when no modules
Browse files Browse the repository at this point in the history
  • Loading branch information
nkh-lab committed Feb 18, 2024
1 parent 3132f75 commit 824b785
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app-cli/src/GetRelayWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ std::string GetRelayWorker::DoBadArgumentText(const std::string& bad_arg)

bool GetRelayWorker::GetState(const std::string& module, int channel, std::string& out)
{
bool ret = true;
bool ret = false;
out = TextUserInterface::kNoModules;
auto modules = relay_manager_->GetModules();

Expand Down
21 changes: 20 additions & 1 deletion app-cli/tests/unit/GetRelayWorkerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,26 @@ TEST_F(GetRelayWorkerTest, NoArgsNoModules)
bool ret = worker.Run(argc, argv, out);

EXPECT_EQ(out, std::string{TextUserInterface::kNoModules});
EXPECT_TRUE(ret);
EXPECT_FALSE(ret);
}

TEST_F(GetRelayWorkerTest, RequestChannelNoModules)
{
const char* argv[] = {"", "module2_2"};
int argc = ARRAY_SIZE(argv);

// Mocking
EXPECT_CALL(*relay_manager_, GetModules()).Times(1).WillOnce(Return(relay_modules_size0_));
//========

GetRelayWorker worker(std::move(relay_manager_));

std::string out;

bool ret = worker.Run(argc, argv, out);

EXPECT_EQ(out, std::string{TextUserInterface::kNoModules});
EXPECT_FALSE(ret);
}

TEST_F(GetRelayWorkerTest, NoArgsOneModule)
Expand Down

0 comments on commit 824b785

Please sign in to comment.