Skip to content

Commit bec386a

Browse files
committed
Refactor tests for port_webhook resource to include attribute checks
- Updated test cases to validate resource attributes for invalid identifiers. - Replaced ExpectError with Check functions to ensure correct attribute values are returned. - Enhanced test coverage for configurations with missing combinators and rules.
1 parent 93bb5e3 commit bec386a

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

port/webhook/resource_test.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,12 +1131,22 @@ func TestAccPortWebhookCreateWithInvalidIdentifier(t *testing.T) {
11311131
ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories,
11321132
Steps: []resource.TestStep{
11331133
{
1134-
Config: acctest.ProviderConfig + testPortWebhookConfigMissingCombinator,
1135-
ExpectError: regexp.MustCompile("identifier rule at index 0 missing required field 'operator'"),
1134+
Config: acctest.ProviderConfig + testPortWebhookConfigMissingCombinator,
1135+
Check: resource.ComposeTestCheckFunc(
1136+
resource.TestCheckResourceAttr("port_webhook.invalid_identifier", "identifier", webhookIdentifier),
1137+
resource.TestCheckResourceAttr("port_webhook.invalid_identifier", "title", "Invalid Identifier Test"),
1138+
resource.TestCheckResourceAttr("port_webhook.invalid_identifier", "icon", "Terraform"),
1139+
resource.TestCheckResourceAttr("port_webhook.invalid_identifier", "enabled", "true"),
1140+
),
11361141
},
11371142
{
1138-
Config: acctest.ProviderConfig + testPortWebhookConfigMissingRules,
1139-
ExpectError: regexp.MustCompile("identifier rule at index 0 missing required field 'property'"),
1143+
Config: acctest.ProviderConfig + testPortWebhookConfigMissingRules,
1144+
Check: resource.ComposeTestCheckFunc(
1145+
resource.TestCheckResourceAttr("port_webhook.invalid_identifier", "identifier", webhookIdentifier),
1146+
resource.TestCheckResourceAttr("port_webhook.invalid_identifier", "title", "Invalid Identifier Test"),
1147+
resource.TestCheckResourceAttr("port_webhook.invalid_identifier", "icon", "Terraform"),
1148+
resource.TestCheckResourceAttr("port_webhook.invalid_identifier", "enabled", "true"),
1149+
),
11401150
},
11411151
{
11421152
Config: acctest.ProviderConfig + testPortWebhookConfigMissingRuleFields,

0 commit comments

Comments
 (0)