Skip to content

Commit 905e66e

Browse files
committed
i keep forgetting about util/slice
1 parent 0d5d587 commit 905e66e

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

provisionersdk/provisionertags_test.go

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package provisionersdk_test
33
import (
44
"testing"
55

6+
"github.com/coder/coder/v2/coderd/util/slice"
67
"github.com/coder/coder/v2/provisionersdk"
78

89
"github.com/google/uuid"
@@ -23,7 +24,7 @@ func TestMutateTags(t *testing.T) {
2324
{
2425
name: "nil tags",
2526
userID: uuid.Nil,
26-
tags: mapslice(nil),
27+
tags: []map[string]string{nil},
2728
want: map[string]string{
2829
provisionersdk.TagScope: provisionersdk.ScopeOrganization,
2930
provisionersdk.TagOwner: "",
@@ -32,15 +33,15 @@ func TestMutateTags(t *testing.T) {
3233
{
3334
name: "empty tags",
3435
userID: uuid.Nil,
35-
tags: mapslice(map[string]string{}),
36+
tags: slice.New(map[string]string{}),
3637
want: map[string]string{
3738
provisionersdk.TagScope: provisionersdk.ScopeOrganization,
3839
provisionersdk.TagOwner: "",
3940
},
4041
},
4142
{
4243
name: "user scope",
43-
tags: mapslice(
44+
tags: slice.New(
4445
map[string]string{provisionersdk.TagScope: provisionersdk.ScopeUser},
4546
),
4647
userID: testUserID,
@@ -51,7 +52,7 @@ func TestMutateTags(t *testing.T) {
5152
},
5253
{
5354
name: "organization scope",
54-
tags: mapslice(
55+
tags: slice.New(
5556
map[string]string{provisionersdk.TagScope: provisionersdk.ScopeOrganization},
5657
),
5758
userID: testUserID,
@@ -62,7 +63,7 @@ func TestMutateTags(t *testing.T) {
6263
},
6364
{
6465
name: "organization scope with owner",
65-
tags: mapslice(
66+
tags: slice.New(
6667
map[string]string{
6768
provisionersdk.TagScope: provisionersdk.ScopeOrganization,
6869
provisionersdk.TagOwner: testUserID.String(),
@@ -76,7 +77,7 @@ func TestMutateTags(t *testing.T) {
7677
},
7778
{
7879
name: "owner tag with no other context",
79-
tags: mapslice(
80+
tags: slice.New(
8081
map[string]string{
8182
provisionersdk.TagOwner: testUserID.String(),
8283
},
@@ -89,7 +90,7 @@ func TestMutateTags(t *testing.T) {
8990
},
9091
{
9192
name: "invalid scope",
92-
tags: mapslice(
93+
tags: slice.New(
9394
map[string]string{provisionersdk.TagScope: "360noscope"},
9495
),
9596
userID: testUserID,
@@ -100,7 +101,7 @@ func TestMutateTags(t *testing.T) {
100101
},
101102
{
102103
name: "merge two empty maps",
103-
tags: mapslice(
104+
tags: slice.New(
104105
map[string]string{},
105106
map[string]string{},
106107
),
@@ -112,7 +113,7 @@ func TestMutateTags(t *testing.T) {
112113
},
113114
{
114115
name: "merge empty map with non-empty map",
115-
tags: mapslice(
116+
tags: slice.New(
116117
map[string]string{},
117118
map[string]string{"foo": "bar"},
118119
),
@@ -125,7 +126,7 @@ func TestMutateTags(t *testing.T) {
125126
},
126127
{
127128
name: "merge non-empty map with empty map",
128-
tags: mapslice(
129+
tags: slice.New(
129130
map[string]string{"foo": "bar"},
130131
map[string]string{},
131132
),
@@ -138,7 +139,7 @@ func TestMutateTags(t *testing.T) {
138139
},
139140
{
140141
name: "merge map with same map",
141-
tags: mapslice(
142+
tags: slice.New(
142143
map[string]string{"foo": "bar"},
143144
map[string]string{"foo": "bar"},
144145
),
@@ -151,7 +152,7 @@ func TestMutateTags(t *testing.T) {
151152
},
152153
{
153154
name: "merge map with override",
154-
tags: mapslice(
155+
tags: slice.New(
155156
map[string]string{"foo": "bar"},
156157
map[string]string{"foo": "baz"},
157158
),
@@ -164,7 +165,7 @@ func TestMutateTags(t *testing.T) {
164165
},
165166
{
166167
name: "do not override empty in second map",
167-
tags: mapslice(
168+
tags: slice.New(
168169
map[string]string{"foo": "bar"},
169170
map[string]string{"foo": ""},
170171
),
@@ -184,7 +185,3 @@ func TestMutateTags(t *testing.T) {
184185
})
185186
}
186187
}
187-
188-
func mapslice(m ...map[string]string) []map[string]string {
189-
return m
190-
}

0 commit comments

Comments
 (0)