mirror of
https://github.com/floci-io/floci-cli.git
synced 2026-11-23 14:10:50 -05:00
fix(cli): exit 2 for every rejected value, not 1 in some commands
config default-product, config profile (unknown action, missing name, --port out of range), update --version, an invalid snapshot name, an invalid az setup container name and an unusable --persist path returned 1, the code for a command that ran and failed. They now return 2 like every other rejected value. A persist directory that cannot be created is still 1. Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
15 files changed
+105
-32
No files matched your search
@@ -339,7 +339,7 @@ class AzSetupCommandTest {
|
||||
|
||||
@Test
|
||||
void aContainerNameThatWouldEscapeIsRefused() {
|
||||
assertEquals(1, run("--container", "../x"));
|
||||
assertEquals(2, run("--container", "../x"), "a rejected value is a usage error");
|
||||
assertTrue(az.calls.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ class ConfigCommandsTest {
|
||||
void createRefusesAPortOutOfRange() throws Exception {
|
||||
Run r = profileCmd(ProductProfile.AZ, "create", "bad", "--port", "70000");
|
||||
|
||||
assertEquals(1, r.exit());
|
||||
assertEquals(2, r.exit(), "a rejected value is a usage error");
|
||||
assertTrue(store().get("bad").isEmpty());
|
||||
}
|
||||
|
||||
|
||||
@@ -39,9 +39,23 @@ class ExitCodeTableTest {
|
||||
"2, completion fish",
|
||||
"2, status --json --no-such-flag",
|
||||
"2, config profile show ../escape",
|
||||
// Accepted by the command line, rejected by the command with 1.
|
||||
"1, update --version not-a-version",
|
||||
"1, config profile create demo --port 0",
|
||||
// Accepted by the command line, rejected by the command: the same code.
|
||||
"2, update --version not-a-version",
|
||||
"2, update --check --version not-a-version",
|
||||
"2, config profile create demo --port 0",
|
||||
"2, config profile create demo --port 70000",
|
||||
"2, config profile bogus",
|
||||
"2, config profile show",
|
||||
"2, config profile create",
|
||||
"2, config profile edit",
|
||||
"2, config profile delete",
|
||||
"2, config default-product nope",
|
||||
"2, snapshot save a/b",
|
||||
"2, snapshot load ..",
|
||||
"2, snapshot delete a/b",
|
||||
"2, gcp snapshot save a/b",
|
||||
"2, az setup --container ../escape",
|
||||
// It ran and the answer is no.
|
||||
"1, config profile show no-such-profile",
|
||||
"1, config profile edit no-such-profile",
|
||||
"1, config validate -f no-such-compose-file.yml",
|
||||
|
||||
@@ -171,7 +171,7 @@ class StartPreflightTest {
|
||||
FakeDocker refused = new FakeDocker(REMOTE);
|
||||
Out relative = start(refused, "--persist", "data", "--container", "floci-gcp-preflight", "--detach");
|
||||
|
||||
assertEquals(1, relative.exit());
|
||||
assertEquals(2, relative.exit(), "a rejected value is a usage error");
|
||||
assertTrue(relative.err().contains("must be an absolute path on the daemon's machine"), relative.err());
|
||||
assertEquals(List.of(), refused.calls);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user