@@ -62,49 +62,66 @@ func TestAccGroupResource(t *testing.T) {
62
62
cfg3 := cfg2
63
63
cfg3 .Members = nil
64
64
65
- resource .Test (t , resource.TestCase {
66
- PreCheck :func () {testAccPreCheck (t ) },
67
- ProtoV6ProviderFactories :testAccProtoV6ProviderFactories ,
68
- Steps : []resource.TestStep {
69
- // Create and Read
70
- {
71
- Config :cfg1 .String (t ),
72
- Check :resource .ComposeAggregateTestCheckFunc (
73
- resource .TestCheckResourceAttr ("coderd_group.test" ,"name" ,"example-group" ),
74
- resource .TestCheckResourceAttr ("coderd_group.test" ,"display_name" ,"Example Group" ),
75
- resource .TestCheckResourceAttr ("coderd_group.test" ,"avatar_url" ,"https://google.com" ),
76
- resource .TestCheckResourceAttr ("coderd_group.test" ,"quota_allowance" ,"100" ),
77
- resource .TestCheckResourceAttr ("coderd_group.test" ,"organization_id" ,firstUser .OrganizationIDs [0 ].String ()),
78
- resource .TestCheckResourceAttr ("coderd_group.test" ,"members.#" ,"1" ),
79
- resource .TestCheckResourceAttr ("coderd_group.test" ,"members.0" ,user1 .ID .String ()),
80
- ),
65
+ t .Run ("CreateImportUpdateReadOk" ,func (t * testing.T ) {
66
+ resource .Test (t , resource.TestCase {
67
+ PreCheck :func () {testAccPreCheck (t ) },
68
+ ProtoV6ProviderFactories :testAccProtoV6ProviderFactories ,
69
+ Steps : []resource.TestStep {
70
+ // Create and Read
71
+ {
72
+ Config :cfg1 .String (t ),
73
+ Check :resource .ComposeAggregateTestCheckFunc (
74
+ resource .TestCheckResourceAttr ("coderd_group.test" ,"name" ,"example-group" ),
75
+ resource .TestCheckResourceAttr ("coderd_group.test" ,"display_name" ,"Example Group" ),
76
+ resource .TestCheckResourceAttr ("coderd_group.test" ,"avatar_url" ,"https://google.com" ),
77
+ resource .TestCheckResourceAttr ("coderd_group.test" ,"quota_allowance" ,"100" ),
78
+ resource .TestCheckResourceAttr ("coderd_group.test" ,"organization_id" ,firstUser .OrganizationIDs [0 ].String ()),
79
+ resource .TestCheckResourceAttr ("coderd_group.test" ,"members.#" ,"1" ),
80
+ resource .TestCheckResourceAttr ("coderd_group.test" ,"members.0" ,user1 .ID .String ()),
81
+ ),
82
+ },
83
+ // Import
84
+ {
85
+ Config :cfg1 .String (t ),
86
+ ResourceName :"coderd_group.test" ,
87
+ ImportState :true ,
88
+ ImportStateVerify :true ,
89
+ ImportStateVerifyIgnore : []string {"members" },
90
+ },
91
+ // Update and Read
92
+ {
93
+ Config :cfg2 .String (t ),
94
+ Check :resource .ComposeAggregateTestCheckFunc (
95
+ resource .TestCheckResourceAttr ("coderd_group.test" ,"name" ,"example-group-new" ),
96
+ resource .TestCheckResourceAttr ("coderd_group.test" ,"display_name" ,"Example Group New" ),
97
+ resource .TestCheckResourceAttr ("coderd_group.test" ,"members.#" ,"1" ),
98
+ resource .TestCheckResourceAttr ("coderd_group.test" ,"members.0" ,user2 .ID .String ()),
99
+ ),
100
+ },
101
+ // Unmanaged members
102
+ {
103
+ Config :cfg3 .String (t ),
104
+ Check :resource .ComposeAggregateTestCheckFunc (
105
+ resource .TestCheckNoResourceAttr ("coderd_group.test" ,"members" ),
106
+ ),
107
+ },
81
108
},
82
- // Import
83
- {
84
- Config :cfg1 .String (t ),
85
- ResourceName :"coderd_group.test" ,
86
- ImportState :true ,
87
- ImportStateVerify :true ,
88
- ImportStateVerifyIgnore : []string {"members" },
89
- },
90
- // Update and Read
91
- {
92
- Config :cfg2 .String (t ),
93
- Check :resource .ComposeAggregateTestCheckFunc (
94
- resource .TestCheckResourceAttr ("coderd_group.test" ,"name" ,"example-group-new" ),
95
- resource .TestCheckResourceAttr ("coderd_group.test" ,"display_name" ,"Example Group New" ),
96
- resource .TestCheckResourceAttr ("coderd_group.test" ,"members.#" ,"1" ),
97
- resource .TestCheckResourceAttr ("coderd_group.test" ,"members.0" ,user2 .ID .String ()),
98
- ),
99
- },
100
- // Unmanaged members
101
- {
102
- Config :cfg3 .String (t ),
103
- Check :resource .ComposeAggregateTestCheckFunc (
104
- resource .TestCheckNoResourceAttr ("coderd_group.test" ,"members" ),
105
- ),
109
+ })
110
+ })
111
+
112
+ t .Run ("CreateUnmanagedMembersOk" ,func (t * testing.T ) {
113
+ resource .Test (t , resource.TestCase {
114
+ PreCheck :func () {testAccPreCheck (t ) },
115
+ ProtoV6ProviderFactories :testAccProtoV6ProviderFactories ,
116
+ Steps : []resource.TestStep {
117
+ {
118
+ Config :cfg3 .String (t ),
119
+ Check :resource .ComposeAggregateTestCheckFunc (
120
+ resource .TestCheckNoResourceAttr ("coderd_group.test" ,"members" ),
121
+ ),
122
+ },
106
123
},
107
- },
124
+ })
108
125
})
109
126
}
110
127