Skip to content

Commit

Permalink
Replacing usage of ConfigStateChecks, BoolExact and NullExact types
Browse files Browse the repository at this point in the history
  • Loading branch information
bendbennett committed Jan 23, 2024
1 parent 6b8f4a2 commit 23ffdb0
Show file tree
Hide file tree
Showing 20 changed files with 65 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .changes/unreleased/NOTES-20240122-082628.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind: NOTES
body: 'plancheck: Deprecated `ExpectNullOutputValue` and `ExpectNullOutputValueAtPath`.
Use `ExpectKnownOutputValue` and `ExpectKnownOutputValueAtPath` with
`knownvalue.NullExact` instead'
`knownvalue.Null` instead'
time: 2024-01-22T08:26:28.053303Z
custom:
Issue: "275"
30 changes: 15 additions & 15 deletions helper/resource/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ func ComposeAggregateTestCheckFunc(fs ...TestCheckFunc) TestCheckFunc {
// bool_attribute = true
// }
// `,
// ConfigStateChecks: resource.ConfigStateChecks{
// ConfigStateChecks: []statecheck.StateCheck{
// statecheck.ExpectValueExists(
// "test_resource.one",
// tfjsonpath.New("bool_attribute"),
Expand Down Expand Up @@ -1226,11 +1226,11 @@ func testCheckResourceAttrSet(is *terraform.InstanceState, name string, key stri
// bool_attribute = true
// }
// `,
// ConfigStateChecks: resource.ConfigStateChecks{
// ConfigStateChecks: []statecheck.StateCheck{
// statecheck.ExpectKnownValue(
// "test_resource.one",
// tfjsonpath.New("bool_attribute"),
// knownvalue.BoolExact(true),
// knownvalue.Bool(true),
// ),
// },
// },
Expand Down Expand Up @@ -1357,7 +1357,7 @@ func testCheckResourceAttr(is *terraform.InstanceState, name string, key string,
// string_attribute = "string"
// }
// `,
// ConfigStateChecks: resource.ConfigStateChecks{
// ConfigStateChecks: []statecheck.StateCheck{
// statecheck.ExpectKnownValue(
// "test_resource.one",
// tfjsonpath.New("string_attribute"),
Expand Down Expand Up @@ -1443,7 +1443,7 @@ type CheckResourceAttrWithFunc func(value string) error
// string_attribute = "string"
// }
// `,
// ConfigStateChecks: resource.ConfigStateChecks{
// ConfigStateChecks: []statecheck.StateCheck{
// statecheck.ExpectKnownValue(
// "test_resource.one",
// tfjsonpath.New("string_attribute"),
Expand Down Expand Up @@ -1540,7 +1540,7 @@ func TestCheckResourceAttrWith(name, key string, checkValueFunc CheckResourceAtt
// bool_attribute = true
// }
// `,
// ConfigStateChecks: resource.ConfigStateChecks{
// ConfigStateChecks: []statecheck.StateCheck{
// statecheck.ExpectNoValueExists(
// "test_resource.one",
// tfjsonpath.New("does_not_exist"),
Expand Down Expand Up @@ -1692,7 +1692,7 @@ func testCheckNoResourceAttr(is *terraform.InstanceState, name string, key strin
// string_attribute = "string"
// }
// `,
// ConfigStateChecks: resource.ConfigStateChecks{
// ConfigStateChecks: []statecheck.StateCheck{
// statecheck.ExpectKnownValue(
// "test_resource.one",
// tfjsonpath.New("string_attribute"),
Expand Down Expand Up @@ -1794,12 +1794,12 @@ func testMatchResourceAttr(is *terraform.InstanceState, name string, key string,
// bool_attribute = true
// }
// `,
// ConfigStateChecks: resource.ConfigStateChecks{
// ConfigStateChecks: []statecheck.StateCheck{
// AlterValue(testBool),
// statecheck.ExpectKnownValue(
// "test_resource.one",
// tfjsonpath.New("bool_attribute"),
// knownvalue.BoolExact(*testBool),
// knownvalue.Bool(*testBool),
// ),
// },
// },
Expand Down Expand Up @@ -1914,7 +1914,7 @@ func TestCheckModuleResourceAttrPtr(mp []string, name string, key string, value
// resource "test_resource" "two" {
// bool_attribute = true
// }`,
// ConfigStateChecks: resource.ConfigStateChecks{
// ConfigStateChecks: []statecheck.StateCheck{
// statecheck.ExpectMatchingValues(
// "test_resource.one",
// tfjsonpath.New("bool_attribute"),
Expand Down Expand Up @@ -2058,10 +2058,10 @@ func testCheckResourceAttrPair(isFirst *terraform.InstanceState, nameFirst strin
// value = test_resource.one.bool_attribute
// }
// `,
// ConfigStateChecks: resource.ConfigStateChecks{
// ConfigStateChecks: []statecheck.StateCheck{
// statecheck.ExpectKnownOutputValue(
// "bool_output",
// knownvalue.BoolExact(true),
// knownvalue.Bool(true),
// ),
// },
// },
Expand Down Expand Up @@ -2098,11 +2098,11 @@ func testCheckResourceAttrPair(isFirst *terraform.InstanceState, nameFirst strin
// value = test_resource.one
// }
// `,
// ConfigStateChecks: resource.ConfigStateChecks{
// ConfigStateChecks: []statecheck.StateCheck{
// statecheck.ExpectKnownOutputValueAtPath(
// "test_resource_one_output",
// tfjsonpath.New("bool_attribute"),
// knownvalue.BoolExact(true),
// knownvalue.Bool(true),
// ),
// },
// },
Expand Down Expand Up @@ -2172,7 +2172,7 @@ func TestCheckOutput(name, value string) TestCheckFunc {
// value = test_resource.one
// }
// `,
// ConfigStateChecks: resource.ConfigStateChecks{
// ConfigStateChecks: []statecheck.StateCheck{
// statecheck.ExpectKnownOutputValueAtPath(
// "test_resource_one_output",
// tfjsonpath.New("string_attribute"),
Expand Down
8 changes: 4 additions & 4 deletions helper/resource/testing_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const (
// ]
// }
// `,
// ConfigStateChecks: resource.ConfigStateChecks{
// ConfigStateChecks: []statecheck.StateCheck{
// statecheck.ExpectKnownValue(
// "test_resource.one",
// tfjsonpath.New("set_attribute"),
Expand Down Expand Up @@ -222,7 +222,7 @@ func TestCheckTypeSetElemNestedAttrs(name, attr string, values map[string]string
// }
// }
// `,
// ConfigStateChecks: resource.ConfigStateChecks{
// ConfigStateChecks: []statecheck.StateCheck{
// statecheck.ExpectKnownValue(
// "test_resource.one",
// tfjsonpath.New("set_nested_block"),
Expand Down Expand Up @@ -354,7 +354,7 @@ func TestMatchTypeSetElemNestedAttrs(name, attr string, values map[string]*regex
// ]
// }
// `,
// ConfigStateChecks: resource.ConfigStateChecks{
// ConfigStateChecks: []statecheck.StateCheck{
// statecheck.ExpectKnownValue(
// "test_resource.one",
// tfjsonpath.New("set_attribute"),
Expand Down Expand Up @@ -452,7 +452,7 @@ func TestCheckTypeSetElemAttr(name, attr, value string) TestCheckFunc {
// "value2"
// ]
// }`,
// ConfigStateChecks: resource.ConfigStateChecks{
// ConfigStateChecks: []statecheck.StateCheck{
// statecheck.ExpectContains(
// "test_resource.two",
// tfjsonpath.New("set_attribute"),
Expand Down
4 changes: 2 additions & 2 deletions plancheck/expect_null_output_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ func (e expectNullOutputValue) CheckPlan(ctx context.Context, req CheckPlanReque
// values may differ. For example, terraform-plugin-sdk based providers may have less precise representations of null values, such
// as marking whole maps as null rather than individual element values.
//
// Deprecated: Use ExpectKnownOutputValue with knownvalue.NullExact instead.
// Deprecated: Use ExpectKnownOutputValue with knownvalue.Null instead.
// ExpectNullOutputValue will be removed in the next major version release.
//
// [ExpectKnownOutputValue]: https://pkg.go.dev/github.com/hashicorp/terraform-plugin-testing/plancheck#ExpectKnownOutputValue
// [NullExact]: https://pkg.go.dev/github.com/hashicorp/terraform-plugin-testing/knownvalue#NullExact
// [Null]: https://pkg.go.dev/github.com/hashicorp/terraform-plugin-testing/knownvalue#Null
func ExpectNullOutputValue(outputAddress string) PlanCheck {
return expectNullOutputValue{
outputAddress: outputAddress,
Expand Down
4 changes: 2 additions & 2 deletions plancheck/expect_null_output_value_at_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ func (e expectNullOutputValueAtPath) CheckPlan(ctx context.Context, req CheckPla
// values may differ. For example, terraform-plugin-sdk based providers may have less precise representations of null values, such
// as marking whole maps as null rather than individual element values.
//
// Deprecated: Use ExpectKnownOutputValueAtPath with knownvalue.NullExact instead.
// Deprecated: Use ExpectKnownOutputValueAtPath with knownvalue.Null instead.
// ExpectNullOutputValueAtPath will be removed in the next major version release.
//
// [ExpectKnownOutputValueAtPath]: https://pkg.go.dev/github.com/hashicorp/terraform-plugin-testing/plancheck#ExpectKnownOutputValueAtPath
// [NullExact]: https://pkg.go.dev/github.com/hashicorp/terraform-plugin-testing/knownvalue#NullExact
// [Null]: https://pkg.go.dev/github.com/hashicorp/terraform-plugin-testing/knownvalue#Null
func ExpectNullOutputValueAtPath(outputAddress string, valuePath tfjsonpath.Path) PlanCheck {
return expectNullOutputValueAtPath{
outputAddress: outputAddress,
Expand Down
2 changes: 1 addition & 1 deletion statecheck/expect_contains_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func ExampleExpectContains() {
"value2"
]
}`,
ConfigStateChecks: resource.ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectContains(
"test_resource.two",
tfjsonpath.New("set_attribute"),
Expand Down
14 changes: 7 additions & 7 deletions statecheck/expect_contains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestExpectContains_CheckState_ResourceOneNotFound(t *testing.T) {
Config: `resource "test_resource" "one" {}
resource "test_resource" "two" {}`,
ConfigStateChecks: r.ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectContains(
"does_not_exist_one",
tfjsonpath.New("bool_attribute"),
Expand Down Expand Up @@ -56,7 +56,7 @@ func TestExpectContains_CheckState_ResourceTwoNotFound(t *testing.T) {
Config: `resource "test_resource" "one" {}
resource "test_resource" "two" {}`,
ConfigStateChecks: r.ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectContains(
"test_resource.one",
tfjsonpath.New("bool_attribute"),
Expand Down Expand Up @@ -84,7 +84,7 @@ func TestExpectContains_CheckState_AttributeOneNotFound(t *testing.T) {
Config: `resource "test_resource" "one" {}
resource "test_resource" "two" {}`,
ConfigStateChecks: r.ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectContains(
"test_resource.one",
tfjsonpath.New("does_not_exist_one"),
Expand Down Expand Up @@ -112,7 +112,7 @@ func TestExpectContains_CheckState_AttributeTwoNotFound(t *testing.T) {
Config: `resource "test_resource" "one" {}
resource "test_resource" "two" {}`,
ConfigStateChecks: r.ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectContains(
"test_resource.one",
tfjsonpath.New("bool_attribute"),
Expand Down Expand Up @@ -142,7 +142,7 @@ func TestExpectContains_CheckState_AttributeOneNotSet(t *testing.T) {
}
resource "test_resource" "two" {}`,
ConfigStateChecks: r.ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectContains(
"test_resource.one",
tfjsonpath.New("bool_attribute"),
Expand Down Expand Up @@ -178,7 +178,7 @@ func TestExpectContains_CheckState_NotFound(t *testing.T) {
"value2"
]
}`,
ConfigStateChecks: r.ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectContains(
"test_resource.two",
tfjsonpath.New("set_attribute"),
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestExpectContains_CheckState_Found(t *testing.T) {
"value2"
]
}`,
ConfigStateChecks: r.ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectContains(
"test_resource.two",
tfjsonpath.New("set_attribute"),
Expand Down
4 changes: 2 additions & 2 deletions statecheck/expect_known_output_value_at_path_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ func ExampleExpectKnownOutputValueAtPath() {
value = test_resource.one
}
`,
ConfigStateChecks: resource.ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectKnownOutputValueAtPath(
"test_resource_one_output",
tfjsonpath.New("bool_attribute"),
knownvalue.BoolExact(true),
knownvalue.Bool(true),
),
},
},
Expand Down
2 changes: 1 addition & 1 deletion statecheck/expect_known_output_value_at_path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_String_Custom(t *testing.T) {
value = test_resource.one
}
`,
ConfigStateChecks: r.ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectKnownOutputValueAtPath(
"test_resource_one_output",
tfjsonpath.New("string_attribute"),
Expand Down
4 changes: 2 additions & 2 deletions statecheck/expect_known_output_value_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ func ExampleExpectKnownOutputValue() {
value = test_resource.one.bool_attribute
}
`,
ConfigStateChecks: resource.ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectKnownOutputValue(
"bool_output",
knownvalue.BoolExact(true),
knownvalue.Bool(true),
),
},
},
Expand Down
2 changes: 1 addition & 1 deletion statecheck/expect_known_output_value_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ func TestExpectKnownOutputValue_CheckState_String_Custom(t *testing.T) {
value = test_resource.one.string_attribute
}
`,
ConfigStateChecks: r.ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectKnownOutputValue(
"string_output",
StringContains("str")),
Expand Down
4 changes: 2 additions & 2 deletions statecheck/expect_known_value_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ func ExampleExpectKnownValue() {
bool_attribute = true
}
`,
ConfigStateChecks: resource.ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectKnownValue(
"test_resource.one",
tfjsonpath.New("bool_attribute"),
knownvalue.BoolExact(true),
knownvalue.Bool(true),
),
},
},
Expand Down
8 changes: 4 additions & 4 deletions statecheck/expect_known_value_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ func TestExpectKnownValue_CheckState_BoolPointer(t *testing.T) {
bool_attribute = true
}
`,
ConfigStateChecks: r.ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
AlterValue(testBool),
statecheck.ExpectKnownValue(
"test_resource.one",
tfjsonpath.New("bool_attribute"),
knownvalue.BoolExact(*testBool),
knownvalue.Bool(*testBool),
),
},
},
Expand Down Expand Up @@ -1226,7 +1226,7 @@ func TestExpectKnownValue_CheckState_SetNestedBlock_Custom(t *testing.T) {
}
}
`,
ConfigStateChecks: r.ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectKnownValue(
"test_resource.one",
tfjsonpath.New("set_nested_block"),
Expand Down Expand Up @@ -1354,7 +1354,7 @@ func TestExpectKnownValue_CheckState_String_Custom(t *testing.T) {
string_attribute = "string"
}
`,
ConfigStateChecks: r.ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectKnownValue(
"test_resource.one",
tfjsonpath.New("string_attribute"),
Expand Down
2 changes: 1 addition & 1 deletion statecheck/expect_matching_values_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func ExampleExpectMatchingValues() {
resource "test_resource" "two" {
bool_attribute = true
}`,
ConfigStateChecks: resource.ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectMatchingValues(
"test_resource.one",
tfjsonpath.New("bool_attribute"),
Expand Down
Loading

0 comments on commit 23ffdb0

Please sign in to comment.