Skip to content

Commit 4efb175

Browse files
Strengthen plan check assertions for ruleset insertion test
- Add granular plan check using plancheck.ExpectKnownValue to verify that exactly one nested block is added (ruleset.# changes from 3 to 4) - This provides more specific validation than just checking for Update action - Addresses review comment about strengthening plan check assertions
1 parent bdfa430 commit 4efb175

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

cloudstack/resource_cloudstack_network_acl_rule_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ import (
2626

2727
"github.com/apache/cloudstack-go/v2/cloudstack"
2828
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
29+
"github.com/hashicorp/terraform-plugin-testing/knownvalue"
2930
"github.com/hashicorp/terraform-plugin-testing/plancheck"
3031
"github.com/hashicorp/terraform-plugin-testing/terraform"
32+
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
3133
)
3234

3335
func TestAccCloudStackNetworkACLRule_basic(t *testing.T) {
@@ -565,6 +567,12 @@ func TestAccCloudStackNetworkACLRule_ruleset_insert_plan_check(t *testing.T) {
565567
// Verify that only 1 rule is being added (the new rule 20)
566568
// and the existing rules (10, 30, 50) are not being modified
567569
plancheck.ExpectResourceAction("cloudstack_network_acl_rule.plan_check", plancheck.ResourceActionUpdate),
570+
// Verify that ruleset.# is changing from 3 to 4 (exactly one block added)
571+
plancheck.ExpectKnownValue(
572+
"cloudstack_network_acl_rule.plan_check",
573+
tfjsonpath.New("ruleset"),
574+
knownvalue.SetSizeExact(4),
575+
),
568576
},
569577
},
570578
Check: resource.ComposeTestCheckFunc(

0 commit comments

Comments
 (0)