From 0628383b0214d75127ccfeb5cd651064c23496cd Mon Sep 17 00:00:00 2001 From: milldr Date: Thu, 9 Jan 2025 16:02:57 -0500 Subject: [PATCH 1/4] separate test cases --- tests/test-cases/complete.yaml | 199 --------------------------------- tests/test-cases/core.yaml | 64 +++++++++++ tests/test-cases/demos.yaml | 135 ++++++++++++++++++++++ 3 files changed, 199 insertions(+), 199 deletions(-) create mode 100644 tests/test-cases/core.yaml create mode 100644 tests/test-cases/demos.yaml diff --git a/tests/test-cases/complete.yaml b/tests/test-cases/complete.yaml index c902f596f..5b3f10e76 100644 --- a/tests/test-cases/complete.yaml +++ b/tests/test-cases/complete.yaml @@ -1,203 +1,4 @@ tests: - - name: "which atmos" - enabled: true - description: "Ensure atmos CLI is installed and we're using the one that was built." - workdir: "../" - command: "which" - args: - - "atmos" - expect: - stdout: - - '(build[/\\]atmos|atmos[/\\]atmos)' - stderr: - - "^$" - exit_code: 0 - - - name: "atmos" - enabled: true - description: "Verify atmos CLI reports missing stacks directory." - workdir: "../" - command: "atmos" - expect: - stdout: - - "atmos.yaml CLI config file specifies the directory for Atmos stacks as stacks," - - "but the directory does not exist." - stderr: - - "^$" - exit_code: 0 - - - name: atmos --help - enabled: true - description: "Ensure atmos CLI help command lists available commands." - workdir: "../examples/demo-stacks" - command: "atmos" - args: - - "--help" - expect: - stdout: - - "Available Commands:" - - "\\batlantis\\b" - - "\\baws\\b" - - "\\bcompletion\\b" - - "\\bdescribe\\b" - - "\\bdocs\\b" - - "\\bhelmfile\\b" - - "\\bhelp\\b" - - "\\blist\\b" - - "\\bpro\\b" - - "\\bterraform\\b" - - "\\bvalidate\\b" - - "\\bvendor\\b" - - "\\bversion\\b" - - "\\bworkflow\\b" - - "Flags:" - - "for more information about a command" - stderr: - - "^$" - exit_code: 0 - - - name: atmos version - enabled: true - description: "Check that atmos version command outputs version details." - workdir: "../examples/demo-stacks" - command: "atmos" - args: - - "version" - expect: - stdout: - - '👽 Atmos (\d+\.\d+\.\d+|test) on [a-z]+/[a-z0-9]+' - stderr: - - "^$" - exit_code: 0 - - - name: atmos version --check - enabled: true - description: "Verify atmos version --check command functions correctly." - workdir: "../examples/demo-stacks" - command: "atmos" - args: - - "version" - - "--check" - expect: - stdout: - - '👽 Atmos (\d+\.\d+\.\d+|test) on [a-z]+/[a-z0-9]+' - stderr: - - "^$" - exit_code: 0 - - - name: atmos docs - enabled: false - description: "Ensure atmos docs command executes without errors." - workdir: "../" - command: "atmos" - args: - - "docs" - expect: - exit_code: 0 - stderr: - - "^$" - - - name: atmos docs myapp - enabled: true - description: "Validate atmos docs command outputs documentation for a specific component." - workdir: "../examples/demo-stacks/" - command: "atmos" - args: - - "docs" - - "myapp" - expect: - stdout: - - "Example Terraform Weather Component" - stderr: - - "^$" - exit_code: 0 - - - name: atmos non-existent - enabled: true - description: "Ensure atmos CLI returns an error for a non-existent command." - workdir: "../" - command: "atmos" - args: - - "non-existent" - expect: - stderr: - - 'unknown command "non-existent" for "atmos"' - exit_code: 1 - - - name: atmos terraform non-existent - enabled: false - description: "Ensure atmos CLI returns an error for a non-existent command." - workdir: "../" - command: "atmos" - args: - - "terraform" - - "non-existent" - expect: - stderr: - - 'unknown command "non-existent" for "atmos"' - exit_code: 1 - - - name: atmos describe config -f yaml - enabled: true - description: "Ensure atmos CLI outputs the Atmos configuration in YAML." - workdir: "../examples/demo-stacks/" - command: "atmos" - args: - - "describe" - - "config" - - "-f" - - "yaml" - expect: - stdout: - - 'append_user_agent: Atmos/(\d+\.\d+\.\d+|test) \(Cloud Posse; \+https:\/\/atmos\.tools\)' - stderr: - - "^$" - exit_code: 0 - - - name: atmos describe config - enabled: true - description: "Ensure atmos CLI outputs the Atmos configuration in JSON." - workdir: "../examples/demo-stacks/" - command: "atmos" - args: - - "describe" - - "config" - expect: - stdout: - - '"append_user_agent": "Atmos/(\d+\.\d+\.\d+|test) \(Cloud Posse; \+https:\/\/atmos\.tools\)"' - stderr: - - "^$" - exit_code: 0 - - - name: atmos greet with args - enabled: true - description: "Validate atmos custom command greet runs with argument provided." - workdir: "../examples/demo-custom-command/" - command: "atmos" - args: - - "greet" - - "Andrey" - expect: - stdout: - - "Hello, Andrey\n" - stderr: - - "^$" - exit_code: 0 - - - name: atmos greet without args - enabled: true - description: "Validate atmos custom command greet runs without argument provided." - workdir: "../examples/demo-custom-command/" - command: "atmos" - args: - - "greet" - expect: - stdout: - - "Hello, John Doe\n" - stderr: - - "^$" - exit_code: 0 - - name: atmos circuit-breaker enabled: true description: "Ensure atmos breaks the infinite loop when shell depth exceeds maximum (10)." diff --git a/tests/test-cases/core.yaml b/tests/test-cases/core.yaml new file mode 100644 index 000000000..6886bf3bf --- /dev/null +++ b/tests/test-cases/core.yaml @@ -0,0 +1,64 @@ +tests: + - name: "which atmos" + enabled: true + description: "Ensure atmos CLI is installed and we're using the one that was built." + workdir: "../" + command: "which" + args: + - "atmos" + expect: + stdout: + - '(build[/\\]atmos|atmos[/\\]atmos)' + stderr: + - "^$" + exit_code: 0 + + - name: "atmos" + enabled: true + description: "Verify atmos CLI reports missing stacks directory." + workdir: "../" + command: "atmos" + expect: + stdout: + - "atmos.yaml CLI config file specifies the directory for Atmos stacks as stacks," + - "but the directory does not exist." + stderr: + - "^$" + exit_code: 0 + + - name: atmos docs + enabled: false + description: "Ensure atmos docs command executes without errors." + workdir: "../" + command: "atmos" + args: + - "docs" + expect: + exit_code: 0 + stderr: + - "^$" + + - name: atmos non-existent + enabled: true + description: "Ensure atmos CLI returns an error for a non-existent command." + workdir: "../" + command: "atmos" + args: + - "non-existent" + expect: + stderr: + - 'unknown command "non-existent" for "atmos"' + exit_code: 1 + + - name: atmos terraform non-existent + enabled: false + description: "Ensure atmos CLI returns an error for a non-existent command." + workdir: "../" + command: "atmos" + args: + - "terraform" + - "non-existent" + expect: + stderr: + - 'unknown command "non-existent" for "atmos"' + exit_code: 1 diff --git a/tests/test-cases/demos.yaml b/tests/test-cases/demos.yaml new file mode 100644 index 000000000..ec85e1fd0 --- /dev/null +++ b/tests/test-cases/demos.yaml @@ -0,0 +1,135 @@ +tests: + - name: atmos --help + enabled: true + description: "Ensure atmos CLI help command lists available commands." + workdir: "../examples/demo-stacks" + command: "atmos" + args: + - "--help" + expect: + stdout: + - "Available Commands:" + - "\\batlantis\\b" + - "\\baws\\b" + - "\\bcompletion\\b" + - "\\bdescribe\\b" + - "\\bdocs\\b" + - "\\bhelmfile\\b" + - "\\bhelp\\b" + - "\\blist\\b" + - "\\bpro\\b" + - "\\bterraform\\b" + - "\\bvalidate\\b" + - "\\bvendor\\b" + - "\\bversion\\b" + - "\\bworkflow\\b" + - "Flags:" + - "for more information about a command" + stderr: + - "^$" + exit_code: 0 + + - name: atmos version + enabled: true + description: "Check that atmos version command outputs version details." + workdir: "../examples/demo-stacks" + command: "atmos" + args: + - "version" + expect: + stdout: + - '👽 Atmos (\d+\.\d+\.\d+|test) on [a-z]+/[a-z0-9]+' + stderr: + - "^$" + exit_code: 0 + + - name: atmos version --check + enabled: true + description: "Verify atmos version --check command functions correctly." + workdir: "../examples/demo-stacks" + command: "atmos" + args: + - "version" + - "--check" + expect: + stdout: + - '👽 Atmos (\d+\.\d+\.\d+|test) on [a-z]+/[a-z0-9]+' + stderr: + - "^$" + exit_code: 0 + + - name: atmos docs myapp + enabled: true + description: "Validate atmos docs command outputs documentation for a specific component." + workdir: "../examples/demo-stacks/" + command: "atmos" + args: + - "docs" + - "myapp" + expect: + stdout: + - "Example Terraform Weather Component" + stderr: + - "^$" + exit_code: 0 + + - name: atmos describe config -f yaml + enabled: true + description: "Ensure atmos CLI outputs the Atmos configuration in YAML." + workdir: "../examples/demo-stacks/" + command: "atmos" + args: + - "describe" + - "config" + - "-f" + - "yaml" + expect: + stdout: + - 'append_user_agent: Atmos/(\d+\.\d+\.\d+|test) \(Cloud Posse; \+https:\/\/atmos\.tools\)' + stderr: + - "^$" + exit_code: 0 + + - name: atmos describe config + enabled: true + description: "Ensure atmos CLI outputs the Atmos configuration in JSON." + workdir: "../examples/demo-stacks/" + command: "atmos" + args: + - "describe" + - "config" + expect: + stdout: + - '"append_user_agent": "Atmos/(\d+\.\d+\.\d+|test) \(Cloud Posse; \+https:\/\/atmos\.tools\)"' + stderr: + - "^$" + exit_code: 0 + + - name: atmos greet with args + enabled: true + description: "Validate atmos custom command greet runs with argument provided." + workdir: "../examples/demo-custom-command/" + command: "atmos" + args: + - "greet" + - "Andrey" + expect: + stdout: + - "Hello, Andrey\n" + stderr: + - "^$" + exit_code: 0 + + - name: atmos greet without args + enabled: true + description: "Validate atmos custom command greet runs without argument provided." + workdir: "../examples/demo-custom-command/" + command: "atmos" + args: + - "greet" + expect: + stdout: + - "Hello, John Doe\n" + stderr: + - "^$" + exit_code: 0 From bd8048697a58cd4a9620932b35d67965f52da206 Mon Sep 17 00:00:00 2001 From: milldr Date: Thu, 9 Jan 2025 21:28:41 -0500 Subject: [PATCH 2/4] separated demo tests into each example --- tests/test-cases/demo-custom-command.yaml | 29 +++++++++++++++++++ .../{demos.yaml => demo-stacks.yaml} | 29 ------------------- 2 files changed, 29 insertions(+), 29 deletions(-) create mode 100644 tests/test-cases/demo-custom-command.yaml rename tests/test-cases/{demos.yaml => demo-stacks.yaml} (79%) diff --git a/tests/test-cases/demo-custom-command.yaml b/tests/test-cases/demo-custom-command.yaml new file mode 100644 index 000000000..5bd9ab719 --- /dev/null +++ b/tests/test-cases/demo-custom-command.yaml @@ -0,0 +1,29 @@ +tests: + - name: atmos greet with args + enabled: true + description: "Validate atmos custom command greet runs with argument provided." + workdir: "../examples/demo-custom-command/" + command: "atmos" + args: + - "greet" + - "Andrey" + expect: + stdout: + - "Hello, Andrey\n" + stderr: + - "^$" + exit_code: 0 + + - name: atmos greet without args + enabled: true + description: "Validate atmos custom command greet runs without argument provided." + workdir: "../examples/demo-custom-command/" + command: "atmos" + args: + - "greet" + expect: + stdout: + - "Hello, John Doe\n" + stderr: + - "^$" + exit_code: 0 diff --git a/tests/test-cases/demos.yaml b/tests/test-cases/demo-stacks.yaml similarity index 79% rename from tests/test-cases/demos.yaml rename to tests/test-cases/demo-stacks.yaml index ec85e1fd0..a50c6d89f 100644 --- a/tests/test-cases/demos.yaml +++ b/tests/test-cases/demo-stacks.yaml @@ -104,32 +104,3 @@ tests: stderr: - "^$" exit_code: 0 - - - name: atmos greet with args - enabled: true - description: "Validate atmos custom command greet runs with argument provided." - workdir: "../examples/demo-custom-command/" - command: "atmos" - args: - - "greet" - - "Andrey" - expect: - stdout: - - "Hello, Andrey\n" - stderr: - - "^$" - exit_code: 0 - - - name: atmos greet without args - enabled: true - description: "Validate atmos custom command greet runs without argument provided." - workdir: "../examples/demo-custom-command/" - command: "atmos" - args: - - "greet" - expect: - stdout: - - "Hello, John Doe\n" - stderr: - - "^$" - exit_code: 0 From d3dfc80f9652b949211b570910cf848accc4a9b2 Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Fri, 10 Jan 2025 10:15:34 -0800 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Erik Osterman (CEO @ Cloud Posse) --- tests/test-cases/core.yaml | 4 ++-- tests/test-cases/demo-custom-command.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test-cases/core.yaml b/tests/test-cases/core.yaml index 6886bf3bf..02c656ab7 100644 --- a/tests/test-cases/core.yaml +++ b/tests/test-cases/core.yaml @@ -27,7 +27,7 @@ tests: exit_code: 0 - name: atmos docs - enabled: false + enabled: true description: "Ensure atmos docs command executes without errors." workdir: "../" command: "atmos" @@ -51,7 +51,7 @@ tests: exit_code: 1 - name: atmos terraform non-existent - enabled: false + enabled: true description: "Ensure atmos CLI returns an error for a non-existent command." workdir: "../" command: "atmos" diff --git a/tests/test-cases/demo-custom-command.yaml b/tests/test-cases/demo-custom-command.yaml index 5bd9ab719..e5cd2f83b 100644 --- a/tests/test-cases/demo-custom-command.yaml +++ b/tests/test-cases/demo-custom-command.yaml @@ -6,10 +6,10 @@ tests: command: "atmos" args: - "greet" - - "Andrey" + - "Neo" expect: stdout: - - "Hello, Andrey\n" + - "Hello, Neo\n" stderr: - "^$" exit_code: 0 From 6612f0d7bbe947e86b27c1abab2a500eefe26271 Mon Sep 17 00:00:00 2001 From: "Erik Osterman (CEO @ Cloud Posse)" Date: Fri, 10 Jan 2025 16:13:25 -0600 Subject: [PATCH 4/4] Update tests/test-cases/core.yaml --- tests/test-cases/core.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-cases/core.yaml b/tests/test-cases/core.yaml index 02c656ab7..7b022f333 100644 --- a/tests/test-cases/core.yaml +++ b/tests/test-cases/core.yaml @@ -51,7 +51,7 @@ tests: exit_code: 1 - name: atmos terraform non-existent - enabled: true + enabled: false description: "Ensure atmos CLI returns an error for a non-existent command." workdir: "../" command: "atmos"