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 a59f761
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
run: |
build/libusbrelaymodule/tests/component/hidapi/GetAnyHidDeviceInfoTest
- name: Run CLI APP getrelay
continue-on-error: true
run: |
build/app-cli/getrelay
build/app-cli/getrelay -v
Expand All @@ -46,6 +47,7 @@ jobs:
run: |
tools/build-portable-linux.sh
- name: Run Portable CLI APP getrelay
continue-on-error: true
run: |
build/portable/getrelay
build/portable/getrelay -v
Expand All @@ -58,6 +60,7 @@ jobs:
run: |
tools/build-portable-linux.sh simu gui
- name: Run Portable Simu CLI APP
continue-on-error: true
run: |
build/portable/getrelay
build/portable/setrelay R2_2=1
Expand All @@ -84,6 +87,7 @@ jobs:
run: |
build/libusbrelaymodule/tests/component/hidapi/Release/GetAnyHidDeviceInfoTest.exe
- name: Run getrelay
continue-on-error: true
run: |
build/app-cli/Release/getrelay.exe
build/app-cli/Release/getrelay.exe -v
Expand All @@ -96,6 +100,7 @@ jobs:
run: |
tools/build-portable-windows.bat
- name: Run Portable CLI APP getrelay
continue-on-error: true
run: |
build/portable/getrelay.exe
build/portable/getrelay.exe -v
Expand All @@ -108,6 +113,7 @@ jobs:
run: |
tools/build-portable-windows.bat simu gui
- name: Run Portable Simu CLI APP
continue-on-error: true
run: |
build/portable/getrelay.exe
build/portable/setrelay.exe R2_2=1
Expand Down
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 a59f761

Please sign in to comment.