Skip to content

Conversation

@fatmcgav
Copy link

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.

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`.
@fatmcgav fatmcgav requested a review from denis256 as a code owner October 30, 2024 16:53
@fatmcgav
Copy link
Author

fatmcgav commented Nov 1, 2024

@denis256 Are the test failures there anything I need to worry about?

Looking at the latest run on master, they failed there also so I'm thinking not...

// 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 {
Copy link
Member

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

}

// 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) {
Copy link
Member

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)
Copy link
Member

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?

Copy link
Author

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...

@denis256
Copy link
Member

denis256 commented Nov 1, 2024

I will add a separate PR to fix the master tests

@fatmcgav
Copy link
Author

fatmcgav commented Nov 1, 2024

@denis256 review comments addressed :)

@fatmcgav fatmcgav requested a review from denis256 November 5, 2024 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants