-
-
Notifications
You must be signed in to change notification settings - Fork 121
Refactor terraform CLI tests with mock component #1018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
427bee7
test: refactor terraform CLI tests with mock component
Cerebrovinny c05cfea
Add test fixtures for atmos configuration files
Cerebrovinny aee2abd
Add test fixtures documentation and directory structure
Cerebrovinny 3ca5ace
Sanitize snapshots (#1002)
osterman f1f4cdc
Update tests/fixtures/scenarios/mock-terraform/atmos.yaml
Cerebrovinny 78ab753
Remove inheritance from mock-terraform test scenario
Cerebrovinny a7f6e8e
test: improve terraform integration test reliability
Cerebrovinny 5eb6087
[autofix.ci] apply automated fixes
autofix-ci[bot] 154a323
Merge branch 'main' into tests/fixes
Cerebrovinny 8411f19
Add random test component and remove myapp component
Cerebrovinny 8007383
Update tests/fixtures/scenarios/mock-terraform/stacks/prod/mock.yaml
Cerebrovinny 95dd117
Update tests/fixtures/scenarios/mock-terraform/atmos.yaml
Cerebrovinny 30f49a0
Delete mock terraform test fixtures
Cerebrovinny c6a154a
refactor: update stack configurations and import paths
Cerebrovinny 5e2b478
Update test fixtures and paths for terraform components
Cerebrovinny 2fab060
test: update test cases and add random component fixtures
Cerebrovinny 9587b48
[autofix.ci] apply automated fixes
autofix-ci[bot] e95ffea
Revert "test: update test cases and add random component fixtures"
Cerebrovinny bfc2451
update main tf
Cerebrovinny adcf46e
update tf main
Cerebrovinny 9b53fa6
add variables
Cerebrovinny 5172760
fix fixture file
Cerebrovinny 36babf8
Merge branch 'main' into tests/fixes
Cerebrovinny 0701ec7
increase timeout
Cerebrovinny 8d0addb
Merge branch 'main' into tests/fixes
osterman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
components: | ||
terraform: | ||
base_path: "../../" | ||
apply: | ||
auto_approve: true | ||
clean: | ||
auto_approve: true | ||
deploy_run_init: true | ||
init_run_reconfigure: true | ||
command: terraform | ||
|
||
stacks: | ||
base_path: "stacks" | ||
included_paths: | ||
- "**/*" | ||
excluded_paths: | ||
- "**/templates/**/*" | ||
name_pattern: "{environment}-{component}" | ||
|
||
logs: | ||
file: "/dev/stderr" | ||
level: "Info" |
5 changes: 5 additions & 0 deletions
5
tests/fixtures/scenarios/mock-terraform/components/terraform/mock/backend.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
terraform { | ||
backend "local" { | ||
path = "terraform.tfstate" | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
tests/fixtures/scenarios/mock-terraform/components/terraform/mock/main.tf
Cerebrovinny marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
variable "stage" { | ||
type = string | ||
} | ||
|
||
variable "environment" { | ||
type = string | ||
} | ||
|
||
variable "tenant" { | ||
type = string | ||
} | ||
|
||
variable "foo" { | ||
type = string | ||
default = "foo" | ||
} | ||
|
||
variable "bar" { | ||
type = string | ||
default = "bar" | ||
} | ||
|
||
variable "baz" { | ||
type = string | ||
default = "baz" | ||
} | ||
|
||
# Mock resource for testing | ||
resource "local_file" "mock" { | ||
content = jsonencode({ | ||
foo = var.foo | ||
bar = var.bar | ||
baz = var.baz | ||
stage = var.stage | ||
environment = var.environment | ||
tenant = var.tenant | ||
}) | ||
filename = "${path.module}/mock.json" | ||
} | ||
|
||
output "foo" { | ||
value = var.foo | ||
} | ||
|
||
output "bar" { | ||
value = var.bar | ||
} | ||
|
||
output "baz" { | ||
value = var.baz | ||
} | ||
|
||
output "stage" { | ||
value = var.stage | ||
} | ||
|
||
output "environment" { | ||
value = var.environment | ||
} | ||
|
||
output "tenant" { | ||
value = var.tenant | ||
} |
1 change: 1 addition & 0 deletions
1
tests/fixtures/scenarios/mock-terraform/components/terraform/mock/mock.json
Cerebrovinny marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"bar":"dev-bar","baz":"dev-baz","environment":"dev","foo":"dev-foo","stage":"dev","tenant":"test"} |
10 changes: 10 additions & 0 deletions
10
tests/fixtures/scenarios/mock-terraform/components/terraform/mock/versions.tf
Cerebrovinny marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
terraform { | ||
|
||
|
||
required_providers { | ||
local = { | ||
source = "hashicorp/local" | ||
version = ">= 2.0" | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/fixtures/scenarios/mock-terraform/stacks/catalog/terraform/mock.yaml
Cerebrovinny marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
components: | ||
terraform: | ||
mock: | ||
metadata: | ||
component: mock | ||
backend: | ||
type: local | ||
settings: | ||
component: mock | ||
vars: | ||
foo: "catalog-foo" | ||
bar: "catalog-bar" | ||
baz: "catalog-baz" |
18 changes: 18 additions & 0 deletions
18
tests/fixtures/scenarios/mock-terraform/stacks/dev/mock.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import: | ||
- ../catalog/terraform/mock | ||
|
||
components: | ||
terraform: | ||
mock: | ||
metadata: | ||
component: mock | ||
environment: dev | ||
backend: | ||
type: local | ||
vars: | ||
stage: dev | ||
environment: dev | ||
tenant: test | ||
foo: "dev-foo" | ||
bar: "dev-bar" | ||
baz: "dev-baz" |
18 changes: 18 additions & 0 deletions
18
tests/fixtures/scenarios/mock-terraform/stacks/prod/mock.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import: | ||
- ../catalog/terraform/mock | ||
Cerebrovinny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
components: | ||
terraform: | ||
mock: | ||
metadata: | ||
component: mock | ||
environment: prod | ||
backend: | ||
type: local | ||
vars: | ||
stage: prod | ||
environment: prod | ||
tenant: test | ||
foo: "prod-foo" | ||
bar: "prod-bar" | ||
baz: "prod-baz" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.