-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat: Add support for validating Output Changes
#1459
base: main
Are you sure you want to change the base?
Conversation
This commit updates the `PlanStruct` type to include the `OutputChangesMap` field, which contains a map of output names and their corresponding change. As part of this: * Add new `parseOutputChanges` function * Add new `AssertOutputChangesMapKeyExists` and `RequireOutputChangesMapKeyExists` public functions. * Add test for new functionality. Also bump the `terraform-json` fixture version to `0.13.0` to match the version in `go.mod`.
@denis256 Are the test failures there anything I need to worry about? Looking at the latest run on |
modules/terraform/plan_struct.go
Outdated
// If there are no changes, this returns an empty map instead of erroring | ||
func parseOutputChanges(plan *PlanStruct) map[string]*tfjson.Change { | ||
out := map[string]*tfjson.Change{} | ||
for output_name, change := range plan.RawPlan.OutputChanges { |
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 camel case instead of snake case
@@ -91,6 +105,18 @@ func parseModulePlannedValues(module *tfjson.StateModule) map[string]*tfjson.Sta | |||
return out | |||
} | |||
|
|||
// AssertOutputChangesMapKeyExists checks if the given key exists in the map, failing the test if it does not. | |||
func AssertOutputChangesMapKeyExists(t testing.TestingT, plan *PlanStruct, keyQuery string) { |
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.
AssertOutputChangesMapKeyExists
- seems to be unused, can be added a test for it?
t.Parallel() | ||
|
||
// Retrieve test data from the terraform-json project. | ||
_, jsonData := http_helper.HttpGet(t, changesJsonUrl, nil) |
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.
can the status code also be verified?
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.
Sure... I straight copied this func from TestResourceChangesJson
.
Will apply same tweak there aswell...
I will add a separate PR to fix the master tests |
@denis256 review comments addressed :) |
This commit updates the
PlanStruct
type to include theOutputChangesMap
field, which contains a map of output names and theircorresponding change.
As part of this:
parseOutputChanges
functionAssertOutputChangesMapKeyExists
andRequireOutputChangesMapKeyExists
public functions.terraform-json
fixtureversion to
0.13.0
to match the version ingo.mod
.