-
Notifications
You must be signed in to change notification settings - Fork 0
/
resource_secret_test.go
50 lines (45 loc) · 1.24 KB
/
resource_secret_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package internal
import (
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccResourceSecret_basic(t *testing.T) {
name := "woodpecker_secret.test_secret"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: NewProto6ProviderFactory(),
Steps: []resource.TestStep{
// Create and Read testing
{
Config: secretConfig,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(name, "name", "test_secret"),
resource.TestCheckResourceAttr(name, "value", "test_value"),
),
},
// Import testing
{
ResourceName: name,
ImportState: true,
ImportStateId: "test_secret",
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"value"},
},
// Update/Read testing
{
Config: secretConfig,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(name, "name", "test_secret"),
resource.TestCheckResourceAttr(name, "value", "test_value"),
),
},
},
})
}
var secretConfig = `
resource "woodpecker_secret" "test_secret" {
name = "test_secret"
value = "test_value"
events = ["push"]
}
`