@@ -7,9 +7,11 @@ import (
7
7
"testing"
8
8
"text/template"
9
9
10
+ "github.com/coder/coder/v2/coderd/util/ptr"
10
11
"github.com/coder/terraform-provider-coderd/integration"
11
12
"github.com/google/uuid"
12
13
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
14
+ "github.com/hashicorp/terraform-plugin-testing/plancheck"
13
15
"github.com/stretchr/testify/require"
14
16
)
15
17
@@ -27,15 +29,17 @@ func TestAccProvisionerKeyResource(t *testing.T) {
27
29
URL : client .URL .String (),
28
30
Token : client .SessionToken (),
29
31
30
- OrganizationID : firstOrg ,
31
- Name : "example-provisioner-key" ,
32
+ OrganizationID : & firstOrg ,
33
+ Name : ptr . Ref ( "example-provisioner-key" ) ,
32
34
}
33
35
34
36
cfg2 := cfg1
35
- cfg2 .Name = "different-provisioner-key"
36
- cfg2 .Tags = map [string ]string {
37
+ cfg2 .Tags = ptr .Ref (map [string ]string {
37
38
"wibble" : "wobble" ,
38
- }
39
+ })
40
+
41
+ cfg3 := cfg2
42
+ cfg3 .Name = ptr .Ref ("different-provisioner-key" )
39
43
40
44
resource .Test (t , resource.TestCase {
41
45
IsUnitTest : true ,
@@ -47,6 +51,27 @@ func TestAccProvisionerKeyResource(t *testing.T) {
47
51
},
48
52
{
49
53
Config : cfg2 .String (t ),
54
+ ConfigPlanChecks : resource.ConfigPlanChecks {
55
+ PreApply : []plancheck.PlanCheck {
56
+ plancheck .ExpectResourceAction ("coderd_provisioner_key.test" , plancheck .ResourceActionReplace ),
57
+ },
58
+ },
59
+ },
60
+ {
61
+ Config : cfg2 .String (t ),
62
+ ConfigPlanChecks : resource.ConfigPlanChecks {
63
+ PreApply : []plancheck.PlanCheck {
64
+ plancheck .ExpectResourceAction ("coderd_provisioner_key.test" , plancheck .ResourceActionReplace ),
65
+ },
66
+ },
67
+ },
68
+ {
69
+ Config : cfg3 .String (t ),
70
+ ConfigPlanChecks : resource.ConfigPlanChecks {
71
+ PreApply : []plancheck.PlanCheck {
72
+ plancheck .ExpectResourceAction ("coderd_provisioner_key.test" , plancheck .ResourceActionReplace ),
73
+ },
74
+ },
50
75
},
51
76
},
52
77
})
@@ -56,9 +81,9 @@ type testAccProvisionerKeyResourceConfig struct {
56
81
URL string
57
82
Token string
58
83
59
- OrganizationID uuid.UUID
60
- Name string
61
- Tags map [string ]string
84
+ OrganizationID * uuid.UUID
85
+ Name * string
86
+ Tags * map [string ]string
62
87
}
63
88
64
89
func (c testAccProvisionerKeyResourceConfig ) String (t * testing.T ) string {
0 commit comments