@@ -7,11 +7,13 @@ import (
7
7
"testing"
8
8
"text/template"
9
9
10
- "github.com/coder/coder/v2/coderd/util/ptr"
11
10
"github.com/coder/terraform-provider-coderd/integration"
12
11
"github.com/google/uuid"
13
12
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
13
+ "github.com/hashicorp/terraform-plugin-testing/knownvalue"
14
14
"github.com/hashicorp/terraform-plugin-testing/plancheck"
15
+ "github.com/hashicorp/terraform-plugin-testing/statecheck"
16
+ "github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
15
17
"github.com/stretchr/testify/require"
16
18
)
17
19
@@ -20,7 +22,7 @@ func TestAccProvisionerKeyResource(t *testing.T) {
20
22
t .Skip ("Acceptance tests are disabled." )
21
23
}
22
24
ctx := context .Background ()
23
- client := integration .StartCoder (ctx , t , "license_acc " , true )
25
+ client := integration .StartCoder (ctx , t , "provisioner_key_acc " , true )
24
26
orgs , err := client .Organizations (ctx )
25
27
require .NoError (t , err )
26
28
firstOrg := orgs [0 ].ID
@@ -29,17 +31,17 @@ func TestAccProvisionerKeyResource(t *testing.T) {
29
31
URL : client .URL .String (),
30
32
Token : client .SessionToken (),
31
33
32
- OrganizationID : & firstOrg ,
33
- Name : ptr . Ref ( "example-provisioner-key" ) ,
34
+ OrganizationID : firstOrg ,
35
+ Name : "example-provisioner-key" ,
34
36
}
35
37
36
38
cfg2 := cfg1
37
- cfg2 .Tags = ptr . Ref ( map [string ]string {
39
+ cfg2 .Tags = map [string ]string {
38
40
"wibble" : "wobble" ,
39
- })
41
+ }
40
42
41
43
cfg3 := cfg2
42
- cfg3 .Name = ptr . Ref ( "different-provisioner-key" )
44
+ cfg3 .Name = "different-provisioner-key"
43
45
44
46
resource .Test (t , resource.TestCase {
45
47
IsUnitTest : true ,
@@ -56,13 +58,8 @@ func TestAccProvisionerKeyResource(t *testing.T) {
56
58
plancheck .ExpectResourceAction ("coderd_provisioner_key.test" , plancheck .ResourceActionReplace ),
57
59
},
58
60
},
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
- },
61
+ ConfigStateChecks : []statecheck.StateCheck {
62
+ statecheck .ExpectKnownValue ("coderd_provisioner_key.test" , tfjsonpath .New ("tags" ).AtMapKey ("wibble" ), knownvalue .StringExact ("wobble" )),
66
63
},
67
64
},
68
65
{
@@ -81,13 +78,14 @@ type testAccProvisionerKeyResourceConfig struct {
81
78
URL string
82
79
Token string
83
80
84
- OrganizationID * uuid.UUID
85
- Name * string
86
- Tags * map [string ]string
81
+ OrganizationID uuid.UUID
82
+ Name string
83
+ Tags map [string ]string
87
84
}
88
85
89
86
func (c testAccProvisionerKeyResourceConfig ) String (t * testing.T ) string {
90
87
t .Helper ()
88
+
91
89
tpl := `
92
90
provider coderd {
93
91
url = "{{.URL}}"
0 commit comments