-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
implement plan-diff command #1134
Draft
mcalhoun
wants to merge
21
commits into
main
Choose a base branch
from
atmos/terraform-plan-diff
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,843
−20
Draft
Changes from 14 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2e36456
initial implementation
mcalhoun 8163848
[autofix.ci] apply automated fixes
autofix-ci[bot] 512ae56
Merge branch 'main' into atmos/terraform-plan-diff
mcalhoun 812c640
update formatting
mcalhoun 6a80657
[autofix.ci] apply automated fixes
autofix-ci[bot] db33b24
improve test coverage
mcalhoun b519204
[autofix.ci] apply automated fixes
autofix-ci[bot] 90ef416
fix io.Copy err not being checked
mcalhoun 7420900
[autofix.ci] apply automated fixes
autofix-ci[bot] ac96682
fix io.Copy err not being checked; improve test coverage
mcalhoun 32a34b9
[autofix.ci] apply automated fixes
autofix-ci[bot] e4baed4
fix lint warnings
mcalhoun cbad19a
fix lint errors
mcalhoun 8155d3a
[autofix.ci] apply automated fixes
autofix-ci[bot] 25bd24d
fix some lint errors
mcalhoun 94ab161
fix linting errors
mcalhoun 46107a4
fix linting errors
mcalhoun 2f952f3
[autofix.ci] apply automated fixes
autofix-ci[bot] 11219ce
Merge branch 'main' into atmos/terraform-plan-diff
mcalhoun 3c08702
fix linting errors
mcalhoun d57893f
Merge branch 'main' into atmos/terraform-plan-diff
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 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 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 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,47 @@ | ||
package exec | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/cloudposse/atmos/pkg/schema" | ||
) | ||
|
||
// TestPlanDiffCommandRouting tests that the plan-diff command is correctly routed | ||
// in the ExecuteTerraform function's switch statement. | ||
// | ||
// NOTE: This test will show a linter error when run separately with golangci-lint, | ||
// because ExecuteTerraform is defined in terraform.go and not visible when linting | ||
// this file alone. However, it works correctly when running 'go test' because | ||
// all files in the package are compiled together. | ||
func TestPlanDiffCommandRouting(t *testing.T) { | ||
// Create minimal info with the plan-diff command | ||
info := schema.ConfigAndStacksInfo{ | ||
Command: "terraform", | ||
SubCommand: "plan-diff", | ||
ComponentFromArg: "test-component", | ||
Component: "test-component", | ||
FinalComponent: "test-component", | ||
ComponentIsEnabled: true, | ||
AdditionalArgsAndFlags: []string{"--orig", "test.tfplan"}, | ||
} | ||
|
||
// Execute the function - we expect it to fail because we haven't set up a proper environment | ||
err := ExecuteTerraform(info) // This line will show a linter error but works in tests | ||
|
||
// Verify we get an error since we have an incomplete setup | ||
if err == nil { | ||
t.Fatalf("Expected ExecuteTerraform to fail with incomplete setup") | ||
} | ||
|
||
// Check the error message to make sure it's not indicating that the command wasn't recognized | ||
errMsg := err.Error() | ||
t.Logf("Error: %v", errMsg) | ||
|
||
// If the error indicates that the command wasn't recognized, the test should fail | ||
if strings.Contains(errMsg, "unknown command") || | ||
strings.Contains(errMsg, "unrecognized command") || | ||
strings.Contains(errMsg, "invalid command") { | ||
t.Errorf("Error suggests the plan-diff command wasn't recognized in the switch statement") | ||
} | ||
} |
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.
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.
We have many lint rules disabled in *_test.go files. Is there another linter we should exclude?