From ffc48a3dc67bef9d3c453e3a6bb01265cd9158c2 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Wed, 5 Feb 2025 22:52:54 +0100 Subject: [PATCH] fix custom command invalid error sentence --- cmd/cmd_utils.go | 2 +- tests/fixtures/scenarios/complete/atmos.yaml | 3 ++- ...CLICommands_atmos_invalidCommand.stderr.golden | 8 ++++++++ ...CLICommands_atmos_invalidCommand.stdout.golden | 0 tests/test-cases/complete.yaml | 15 ++++++++++++++- 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 tests/snapshots/TestCLICommands_atmos_invalidCommand.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_invalidCommand.stdout.golden diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index bb153bbdd..9462b17ac 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -222,7 +222,7 @@ func preCustomCommand( } else { // truly invalid, nothing to do u.PrintErrorMarkdownAndExit("Invalid command", errors.New( - fmt.Sprintf("no args, no steps, no sub-commands provided in config for `%s`", cmd.CommandPath()), + fmt.Sprintf("The `%s` command has no steps or subcommands configured.", cmd.CommandPath()), ), "https://atmos.tools/cli/configuration/commands") } } diff --git a/tests/fixtures/scenarios/complete/atmos.yaml b/tests/fixtures/scenarios/complete/atmos.yaml index 41811f20a..2ecc16336 100644 --- a/tests/fixtures/scenarios/complete/atmos.yaml +++ b/tests/fixtures/scenarios/complete/atmos.yaml @@ -243,7 +243,8 @@ commands: > /dev/null - chmod 600 ${KUBECONFIG} - echo ${KUBECONFIG} - + - name: "invalidCommand" + description: "This is an invalid command that neither has steps or sub command" # Integrations integrations: # Atlantis integration diff --git a/tests/snapshots/TestCLICommands_atmos_invalidCommand.stderr.golden b/tests/snapshots/TestCLICommands_atmos_invalidCommand.stderr.golden new file mode 100644 index 000000000..a34a282b3 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_invalidCommand.stderr.golden @@ -0,0 +1,8 @@ + +# Invalid Command + +The atmos invalidCommand command has no steps or subcommands configured. + +For more information, refer to the docs https://atmos.tools/cli/configuration/commands + + diff --git a/tests/snapshots/TestCLICommands_atmos_invalidCommand.stdout.golden b/tests/snapshots/TestCLICommands_atmos_invalidCommand.stdout.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/test-cases/complete.yaml b/tests/test-cases/complete.yaml index 5374e016b..15837d06e 100644 --- a/tests/test-cases/complete.yaml +++ b/tests/test-cases/complete.yaml @@ -32,4 +32,17 @@ tests: - "No workflow exists" - "test-1" - "terraform-plan-all-test-components" - exit_code: 1 \ No newline at end of file + exit_code: 1 + - name: atmos invalidCommand + enabled: true + snapshot: true + description: "Ensure atmos invalidCommand returns error" + workdir: "fixtures/scenarios/complete/" + command: "atmos" + args: + - "invalidCommand" + expect: + diff: [] + stderr: + - "command has no steps or subcommands configured" + exit_code: 1