Skip to content

Commit

Permalink
[cli] add logic to reject ipv4 and snapshots options together
Browse files Browse the repository at this point in the history
  • Loading branch information
sharder996 committed Sep 29, 2023
1 parent 83c6be3 commit 1868102
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/client/cli/cmd/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ mp::ParseCode cmd::List::parse_args(mp::ArgParser* parser)
return ParseCode::CommandLineError;
}

if (parser->isSet(snapshotsOption) && parser->isSet(noIpv4Option))
{
cerr << "IP addresses are not applicable in conjunction with listing snapshots\n";
return ParseCode::CommandLineError;
}

request.set_snapshots(parser->isSet(snapshotsOption));
request.set_request_ipv4(!parser->isSet(noIpv4Option));

Expand Down
5 changes: 5 additions & 0 deletions tests/test_cli_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,11 @@ TEST_F(Client, list_cmd_no_ipv4_ok)
EXPECT_THAT(send_command({"list", "--no-ipv4"}), Eq(mp::ReturnCode::Ok));
}

TEST_F(Client, listCmdFailsWithIpv4AndSnapshots)
{
EXPECT_THAT(send_command({"list", "--no-ipv4", "--snapshots"}), Eq(mp::ReturnCode::CommandLineError));
}

// mount cli tests
// Note: mpt::test_data_path() returns an absolute path
TEST_F(Client, mount_cmd_good_absolute_source_path)
Expand Down

0 comments on commit 1868102

Please sign in to comment.