Add a resource for webhook (#40)

Authored-by: Raul Barreto <raul.barreto@redbull.com>
This commit is contained in:
raulbarreto-delivion
2021-12-14 18:01:40 +01:00
committed by GitHub
parent 8e94aeb33c
commit f7325bc723
3 changed files with 359 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
package bitbucket
import (
"fmt"
"math/rand"
"testing"
"time"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccBitbucketResourceRepositoryWebhook_simple(t *testing.T) {
projectKey := fmt.Sprintf("TEST%v", rand.New(rand.NewSource(time.Now().UnixNano())).Int())
config := fmt.Sprintf(`
resource "bitbucketserver_project" "test" {
key = "%v"
name = "test-project-%v"
}
resource "bitbucketserver_repository" "test" {
project = bitbucketserver_project.test.key
name = "repo"
}
resource "bitbucketserver_repository_webhook" "test" {
project = bitbucketserver_project.test.key
repository = bitbucketserver_repository.test.slug
name = "google"
webhook_url = "https://www.google.com/"
events = ["repo:refs_changed"]
active = true
}
`, projectKey, projectKey)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("bitbucketserver_repository_webhook.test", "project", projectKey),
resource.TestCheckResourceAttr("bitbucketserver_repository_webhook.test", "repository", "repo"),
resource.TestCheckResourceAttr("bitbucketserver_repository_webhook.test", "webhook_url", "https://www.google.com/"),
),
},
},
})
}