@@ -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