Skip to content

Commit

Permalink
Add test for build custom webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhung committed Jun 4, 2024
1 parent 9f9eeef commit a4929d4
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,48 @@ func customWebhookTestCase(webhookType string, t *testing.T) (*testing.T, resour
}
}

func TestAccCustomWebhook_BuildWithIncludePatterns(t *testing.T) {
id := testutil.RandomInt()
name := fmt.Sprintf("webhook-%d", id)
fqrn := fmt.Sprintf("artifactory_build_custom_webhook.%s", name)

params := map[string]interface{}{
"webhookName": name,
}
webhookConfig := util.ExecuteTemplate("TestAccCustomWebhookBuildPatterns", `
resource "artifactory_build_custom_webhook" "{{ .webhookName }}" {
key = "{{ .webhookName }}"
description = "test description"
event_types = ["uploaded"]
criteria {
any_build = false
selected_builds = []
include_patterns = ["foo"]
}
handler {
url = "https://tempurl.org"
payload = "{ \"ref\": \"main\" , \"inputs\": { \"artifact_path\": \"test-repo/repo-path\" } }"
}
}
`, params)

resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ProviderFactories: acctest.ProviderFactories,
CheckDestroy: acctest.VerifyDeleted(fqrn, acctest.CheckRepo),

Steps: []resource.TestStep{
{
Config: webhookConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(fqrn, "criteria.0.include_patterns.#", "1"),
resource.TestCheckResourceAttr(fqrn, "criteria.0.include_patterns.0", "foo"),
),
},
},
})
}

func testCheckWebhook(id string, request *resty.Request) (*resty.Response, error) {
return request.
SetPathParam("webhookKey", id).
Expand Down

0 comments on commit a4929d4

Please sign in to comment.