Skip to content

Commit 93bb5e3

Browse files
committed
fixed tests
1 parent 90014a7 commit 93bb5e3

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

port/webhook/resource_test.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,26 @@ func TestAccPortWebhookCreateWithComplexIdentifier(t *testing.T) {
10071007
resource.TestCheckResourceAttr("port_webhook.complex_identifier", "mappings.0.blueprint", identifier),
10081008
resource.TestCheckResourceAttr("port_webhook.complex_identifier", "mappings.0.operation.type", "create"),
10091009
resource.TestCheckResourceAttr("port_webhook.complex_identifier", "mappings.0.filter", ".headers.\"x-github-event\" == \"push\""),
1010-
resource.TestCheckResourceAttr("port_webhook.complex_identifier", "mappings.0.entity.identifier", "{\"combinator\":\"'and'\",\"rules\":[\"operator\":\"'='\",\"value\":\".body.resources[0]\"}], {\"property\":\"'arn'\"}"),
1010+
resource.TestCheckResourceAttrWith("port_webhook.complex_identifier", "mappings.0.entity.identifier",
1011+
func(value string) error {
1012+
// Check that the identifier contains the expected parts
1013+
if !regexp.MustCompile(`"combinator"\s*:\s*"'and'"`).MatchString(value) {
1014+
return fmt.Errorf("identifier missing combinator: 'and'")
1015+
}
1016+
if !regexp.MustCompile(`"rules"\s*:\s*\[`).MatchString(value) {
1017+
return fmt.Errorf("identifier missing rules array")
1018+
}
1019+
if !regexp.MustCompile(`"property"\s*:\s*"'arn'"`).MatchString(value) {
1020+
return fmt.Errorf("identifier missing property: 'arn'")
1021+
}
1022+
if !regexp.MustCompile(`"operator"\s*:\s*"'='"`).MatchString(value) {
1023+
return fmt.Errorf("identifier missing operator: '='")
1024+
}
1025+
if !regexp.MustCompile(`"value"\s*:\s*"\.body\.resources\[0\]"`).MatchString(value) {
1026+
return fmt.Errorf("identifier missing value: .body.resources[0]")
1027+
}
1028+
return nil
1029+
}),
10111030
resource.TestCheckResourceAttr("port_webhook.complex_identifier", "mappings.0.entity.title", ".body.repository.name"),
10121031
resource.TestCheckResourceAttr("port_webhook.complex_identifier", "mappings.0.entity.properties.url", ".body.repository.html_url"),
10131032
),

0 commit comments

Comments
 (0)