mirror of
https://github.com/Kichiyaki/terraform-provider-woodpecker.git
synced 2024-06-01 18:28:03 +00:00
41 lines
988 B
Go
41 lines
988 B
Go
package internal_test
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
|
|
)
|
|
|
|
func TestSecretDataSource(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
name := uuid.NewString()
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
|
|
Steps: []resource.TestStep{
|
|
{
|
|
Config: fmt.Sprintf(`
|
|
resource "woodpecker_secret" "test_secret" {
|
|
name = "%s"
|
|
value = "test123"
|
|
events = ["push"]
|
|
}
|
|
|
|
data "woodpecker_secret" "test_secret" {
|
|
name = woodpecker_secret.test_secret.name
|
|
}
|
|
`, name),
|
|
Check: resource.ComposeAggregateTestCheckFunc(
|
|
resource.TestCheckResourceAttrSet("data.woodpecker_secret.test_secret", "id"),
|
|
resource.TestCheckResourceAttr("data.woodpecker_secret.test_secret", "name", name),
|
|
resource.TestCheckTypeSetElemAttr("data.woodpecker_secret.test_secret", "events.*", "push"),
|
|
),
|
|
},
|
|
},
|
|
})
|
|
}
|