-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix issue: Generated backend.tf "region" place is random #1102 #1165
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! This looks good to me! Will kick off a build to give you one feedback cycle, but can you also add a regression test? I'm thinking taking one of the generator tests, duplicating it, and running it in a tight loop multiple times to verify it always generates the same file.
I'll really appreciate if someone can give this PR 👀. It will solve a small but very annoying problem. |
It looks like there hasn't been an update to add a regression test yet (as requested in my comment). If anyone has interest to continue this PR to add a regression test, I can pull this fork into a branch into this repo so you can get it on your forks to commit on top of it. |
please have a look. It adds a few test cases to ensure "region" is not being placed in random order. |
tests: add test coverage for RemoteStateConfigToTerraformCode gruntwork-io#1165
Tests added @yorinasub17 @brikis98 |
tests: add regression tests for 1102
tests: improve integration tests for RemoteStateConfigToTerraformCode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for extending with test cases! The tests look pretty good, but had a few minor issues. Once those are resolved, I can kick off a build!
codegen/generate_test.go
Outdated
"c": 3, | ||
}, | ||
expectedOrdered, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
golang maps are unordered when they are stored, so changing the order in the call here has no effect. Drop one of the test cases here, and instead update the test routine to call the function N times (20 like the other one?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
test/integration_test.go
Outdated
expected, _ := ioutil.ReadFile(filepath.Join(generateTestCase, "backend.tf")) | ||
for i := 1; i < 20; i++ { | ||
runTerragruntCommand(t, fmt.Sprintf("terragrunt output -no-color -json --terragrunt-non-interactive --terragrunt-working-dir %s", generateTestCase), &stdout, &stderr) | ||
actual, _ := ioutil.ReadFile(filepath.Join(generateTestCase, "backend.tf")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check errors here instead of throwing them away (with require.NoError
). Need to do this for the call above as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, will change.
test/integration_test.go
Outdated
|
||
runTerragruntCommand(t, fmt.Sprintf("terragrunt output -no-color -json --terragrunt-non-interactive --terragrunt-working-dir %s", generateTestCase), &stdout, &stderr) | ||
expected, _ := ioutil.ReadFile(filepath.Join(generateTestCase, "backend.tf")) | ||
for i := 1; i < 20; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 0-indexing:
for i := 1; i < 20; i++ { | |
for i := 0; i < 20; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
tests: small adjustments for integration tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updates LGTM! Going to kick off a build, and if it passes, will merge this in!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build passed, so will go through to merge! Thanks for your contribution!
No description provided.