-
Notifications
You must be signed in to change notification settings - Fork 14
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
Adding State Checks for Known Type and Value, and Sensitive Checks #275
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
f67b3e7
Adding StateCheck interface (#266)
bendbennett eed2a12
Adding validation to ensure state checks are only defined for config …
bendbennett d4e31d3
Adding ExpectKnownValue state check (#266)
bendbennett 4e3ca3a
Adding ExpectKnownOutputValue state check (#266)
bendbennett d93aa82
Adding ExpectKnownOutputValueAtPath state check (#266)
bendbennett 598dac8
Modifying ExpectKnown<Value|OutputValue|OutputValueAtPath> to allow f…
bendbennett c78e3e8
Adding ExpectSensitiveValue state check (#266)
bendbennett 1e51693
Adding documentation for state checks and null known value check type…
bendbennett 3d4acf4
Adding to the documentation for the custom known value check (#266)
bendbennett 01fe9a9
Adding changelog entries (#266)
bendbennett fb9fed8
Refactoring to use updated known value check types (#266)
bendbennett 7ff68bc
Correcting documentation for revised naming of known value check type…
bendbennett 5d04859
Renaming nul known value check (#266)
bendbennett a79aea8
Fixing tests (#266)
bendbennett f5abf73
Adding address and path to state check errors (#266)
bendbennett 648730a
Fixing navigation (#266)
bendbennett c74a9e8
Fixing changelog entries
bendbennett 178c2c4
Modifying ExpectKnown<Value|OutputValue|OutputValueAtPath> to handle …
bendbennett c542a70
Deprecating ExpectNullOutputValue and ExpectNullOutputValueAtPath pla…
bendbennett 518c94c
Adding return statements (#266)
bendbennett 35ffc45
Adding change log entry for deprecation of `ExpectNullOutputValue` an…
bendbennett 31f8d5e
Modifying return value of nullExact.String() (#266)
bendbennett 031df21
Renaming variable (#266)
bendbennett 6df33b9
Adding comment for Terraform v1.4.6 (#266)
bendbennett 15330e3
Adding further tests for null exact known value type check (#266)
bendbennett e4e96ac
Merge branch 'main' into bendbennett/issues-266
bendbennett a88a10d
Linting (#266)
bendbennett 6d8f112
Renaming BoolExact to Bool, and NullExact to Null (#266)
bendbennett 04cf3c9
Removing ConfigStateChecks type (#266)
bendbennett 173d4b2
Move execution of ConfigStateChecks (#266)
bendbennett 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: FEATURES | ||
body: 'statecheck: Introduced new `statecheck` package with interface and built-in | ||
state check functionality' | ||
time: 2024-01-11T14:21:26.261094Z | ||
custom: | ||
Issue: "275" |
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,6 @@ | ||
kind: FEATURES | ||
body: 'statecheck: Added `ExpectKnownValue` state check, which asserts that a given | ||
resource attribute has a defined type, and value' | ||
time: 2024-01-11T14:22:23.072321Z | ||
custom: | ||
Issue: "275" |
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,6 @@ | ||
kind: FEATURES | ||
body: 'statecheck: Added `ExpectKnownOutputValue` state check, which asserts that | ||
a given output value has a defined type, and value' | ||
time: 2024-01-11T14:23:14.025585Z | ||
custom: | ||
Issue: "275" |
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,6 @@ | ||
kind: FEATURES | ||
body: 'statecheck: Added `ExpectKnownOutputValueAtPath` plan check, which asserts | ||
that a given output value at a specified path has a defined type, and value' | ||
time: 2024-01-11T14:23:53.633255Z | ||
custom: | ||
Issue: "275" |
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,6 @@ | ||
kind: FEATURES | ||
body: 'statecheck: Added `ExpectSensitiveValue` built-in state check, which asserts | ||
that a given attribute has a sensitive value' | ||
time: 2024-01-11T14:25:44.598583Z | ||
custom: | ||
Issue: "275" |
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,7 @@ | ||
kind: NOTES | ||
body: 'plancheck: Deprecated `ExpectNullOutputValue` and `ExpectNullOutputValueAtPath`. | ||
Use `ExpectKnownOutputValue` and `ExpectKnownOutputValueAtPath` with | ||
`knownvalue.NullExact` instead' | ||
time: 2024-01-22T08:26:28.053303Z | ||
custom: | ||
Issue: "275" |
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,29 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package resource | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
|
||
tfjson "github.com/hashicorp/terraform-json" | ||
"github.com/mitchellh/go-testing-interface" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/statecheck" | ||
) | ||
|
||
func runStateChecks(ctx context.Context, t testing.T, state *tfjson.State, stateChecks []statecheck.StateCheck) error { | ||
t.Helper() | ||
|
||
var result []error | ||
|
||
for _, stateCheck := range stateChecks { | ||
resp := statecheck.CheckStateResponse{} | ||
stateCheck.CheckState(ctx, statecheck.CheckStateRequest{State: state}, &resp) | ||
|
||
result = append(result, resp.Error) | ||
} | ||
|
||
return errors.Join(result...) | ||
} |
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,22 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package resource | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/statecheck" | ||
) | ||
|
||
var _ statecheck.StateCheck = &stateCheckSpy{} | ||
|
||
type stateCheckSpy struct { | ||
err error | ||
called bool | ||
} | ||
|
||
func (s *stateCheckSpy) CheckState(ctx context.Context, req statecheck.CheckStateRequest, resp *statecheck.CheckStateResponse) { | ||
s.called = true | ||
resp.Error = s.err | ||
} |
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
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
Oops, something went wrong.
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.
No more
resource.ComposeAggregateTestCheckFunc
vsresource.ComposeTestCheckFunc
debates!