@@ -3,6 +3,7 @@ package provisionersdk_test
3
3
import (
4
4
"testing"
5
5
6
+ "github.com/coder/coder/v2/coderd/util/slice"
6
7
"github.com/coder/coder/v2/provisionersdk"
7
8
8
9
"github.com/google/uuid"
@@ -23,7 +24,7 @@ func TestMutateTags(t *testing.T) {
23
24
{
24
25
name : "nil tags" ,
25
26
userID : uuid .Nil ,
26
- tags : mapslice ( nil ) ,
27
+ tags : [] map [ string ] string { nil } ,
27
28
want : map [string ]string {
28
29
provisionersdk .TagScope : provisionersdk .ScopeOrganization ,
29
30
provisionersdk .TagOwner : "" ,
@@ -32,15 +33,15 @@ func TestMutateTags(t *testing.T) {
32
33
{
33
34
name : "empty tags" ,
34
35
userID : uuid .Nil ,
35
- tags : mapslice (map [string ]string {}),
36
+ tags : slice . New (map [string ]string {}),
36
37
want : map [string ]string {
37
38
provisionersdk .TagScope : provisionersdk .ScopeOrganization ,
38
39
provisionersdk .TagOwner : "" ,
39
40
},
40
41
},
41
42
{
42
43
name : "user scope" ,
43
- tags : mapslice (
44
+ tags : slice . New (
44
45
map [string ]string {provisionersdk .TagScope : provisionersdk .ScopeUser },
45
46
),
46
47
userID : testUserID ,
@@ -51,7 +52,7 @@ func TestMutateTags(t *testing.T) {
51
52
},
52
53
{
53
54
name : "organization scope" ,
54
- tags : mapslice (
55
+ tags : slice . New (
55
56
map [string ]string {provisionersdk .TagScope : provisionersdk .ScopeOrganization },
56
57
),
57
58
userID : testUserID ,
@@ -62,7 +63,7 @@ func TestMutateTags(t *testing.T) {
62
63
},
63
64
{
64
65
name : "organization scope with owner" ,
65
- tags : mapslice (
66
+ tags : slice . New (
66
67
map [string ]string {
67
68
provisionersdk .TagScope : provisionersdk .ScopeOrganization ,
68
69
provisionersdk .TagOwner : testUserID .String (),
@@ -76,7 +77,7 @@ func TestMutateTags(t *testing.T) {
76
77
},
77
78
{
78
79
name : "owner tag with no other context" ,
79
- tags : mapslice (
80
+ tags : slice . New (
80
81
map [string ]string {
81
82
provisionersdk .TagOwner : testUserID .String (),
82
83
},
@@ -89,7 +90,7 @@ func TestMutateTags(t *testing.T) {
89
90
},
90
91
{
91
92
name : "invalid scope" ,
92
- tags : mapslice (
93
+ tags : slice . New (
93
94
map [string ]string {provisionersdk .TagScope : "360noscope" },
94
95
),
95
96
userID : testUserID ,
@@ -100,7 +101,7 @@ func TestMutateTags(t *testing.T) {
100
101
},
101
102
{
102
103
name : "merge two empty maps" ,
103
- tags : mapslice (
104
+ tags : slice . New (
104
105
map [string ]string {},
105
106
map [string ]string {},
106
107
),
@@ -112,7 +113,7 @@ func TestMutateTags(t *testing.T) {
112
113
},
113
114
{
114
115
name : "merge empty map with non-empty map" ,
115
- tags : mapslice (
116
+ tags : slice . New (
116
117
map [string ]string {},
117
118
map [string ]string {"foo" : "bar" },
118
119
),
@@ -125,7 +126,7 @@ func TestMutateTags(t *testing.T) {
125
126
},
126
127
{
127
128
name : "merge non-empty map with empty map" ,
128
- tags : mapslice (
129
+ tags : slice . New (
129
130
map [string ]string {"foo" : "bar" },
130
131
map [string ]string {},
131
132
),
@@ -138,7 +139,7 @@ func TestMutateTags(t *testing.T) {
138
139
},
139
140
{
140
141
name : "merge map with same map" ,
141
- tags : mapslice (
142
+ tags : slice . New (
142
143
map [string ]string {"foo" : "bar" },
143
144
map [string ]string {"foo" : "bar" },
144
145
),
@@ -151,7 +152,7 @@ func TestMutateTags(t *testing.T) {
151
152
},
152
153
{
153
154
name : "merge map with override" ,
154
- tags : mapslice (
155
+ tags : slice . New (
155
156
map [string ]string {"foo" : "bar" },
156
157
map [string ]string {"foo" : "baz" },
157
158
),
@@ -164,7 +165,7 @@ func TestMutateTags(t *testing.T) {
164
165
},
165
166
{
166
167
name : "do not override empty in second map" ,
167
- tags : mapslice (
168
+ tags : slice . New (
168
169
map [string ]string {"foo" : "bar" },
169
170
map [string ]string {"foo" : "" },
170
171
),
@@ -184,7 +185,3 @@ func TestMutateTags(t *testing.T) {
184
185
})
185
186
}
186
187
}
187
-
188
- func mapslice (m ... map [string ]string ) []map [string ]string {
189
- return m
190
- }
0 commit comments