@@ -66,22 +66,22 @@ func TestProjectsList(t *testing.T) {
66
66
t .Run ("when using a tags filter" , func (t * testing.T ) {
67
67
skipUnlessBeta (t )
68
68
69
- p1 , wTestCleanup1 := createProjectWithOptions (t , client , orgTest , ProjectCreateOptions {
69
+ p1 , pTestCleanup1 := createProjectWithOptions (t , client , orgTest , ProjectCreateOptions {
70
70
Name : randomStringWithoutSpecialChar (t ),
71
71
TagBindings : []* TagBinding {
72
72
{Key : "key1" , Value : "value1" },
73
73
{Key : "key2" , Value : "value2a" },
74
74
},
75
75
})
76
- p2 , wTestCleanup2 := createProjectWithOptions (t , client , orgTest , ProjectCreateOptions {
76
+ p2 , pTestCleanup2 := createProjectWithOptions (t , client , orgTest , ProjectCreateOptions {
77
77
Name : randomStringWithoutSpecialChar (t ),
78
78
TagBindings : []* TagBinding {
79
79
{Key : "key2" , Value : "value2b" },
80
80
{Key : "key3" , Value : "value3" },
81
81
},
82
82
})
83
- t .Cleanup (wTestCleanup1 )
84
- t .Cleanup (wTestCleanup2 )
83
+ t .Cleanup (pTestCleanup1 )
84
+ t .Cleanup (pTestCleanup2 )
85
85
86
86
// List all the workspaces under the given tag
87
87
pl , err := client .Projects .List (ctx , orgTest .Name , & ProjectListOptions {
@@ -247,6 +247,70 @@ func TestProjectsUpdate(t *testing.T) {
247
247
})
248
248
}
249
249
250
+ func TestProjectsAddTagBindings (t * testing.T ) {
251
+ skipUnlessBeta (t )
252
+
253
+ client := testClient (t )
254
+ ctx := context .Background ()
255
+
256
+ pTest , wCleanup := createProject (t , client , nil )
257
+ t .Cleanup (wCleanup )
258
+
259
+ t .Run ("when adding tag bindings to a project" , func (t * testing.T ) {
260
+ tagBindings := []* TagBinding {
261
+ {Key : "foo" , Value : "bar" },
262
+ {Key : "baz" , Value : "qux" },
263
+ }
264
+
265
+ bindings , err := client .Projects .AddTagBindings (ctx , pTest .ID , ProjectAddTagBindingsOptions {
266
+ TagBindings : tagBindings ,
267
+ })
268
+ require .NoError (t , err )
269
+
270
+ assert .Len (t , bindings , 2 )
271
+ assert .Equal (t , tagBindings [0 ].Key , bindings [0 ].Key )
272
+ assert .Equal (t , tagBindings [0 ].Value , bindings [0 ].Value )
273
+ assert .Equal (t , tagBindings [1 ].Key , bindings [1 ].Key )
274
+ assert .Equal (t , tagBindings [1 ].Value , bindings [1 ].Value )
275
+ })
276
+
277
+ t .Run ("when adding 26 tags" , func (t * testing.T ) {
278
+ tagBindings := []* TagBinding {
279
+ {Key : "alpha" },
280
+ {Key : "bravo" },
281
+ {Key : "charlie" },
282
+ {Key : "delta" },
283
+ {Key : "echo" },
284
+ {Key : "foxtrot" },
285
+ {Key : "golf" },
286
+ {Key : "hotel" },
287
+ {Key : "india" },
288
+ {Key : "juliet" },
289
+ {Key : "kilo" },
290
+ {Key : "lima" },
291
+ {Key : "mike" },
292
+ {Key : "november" },
293
+ {Key : "oscar" },
294
+ {Key : "papa" },
295
+ {Key : "quebec" },
296
+ {Key : "romeo" },
297
+ {Key : "sierra" },
298
+ {Key : "tango" },
299
+ {Key : "uniform" },
300
+ {Key : "victor" },
301
+ {Key : "whiskey" },
302
+ {Key : "xray" },
303
+ {Key : "yankee" },
304
+ {Key : "zulu" },
305
+ }
306
+
307
+ _ , err := client .Workspaces .AddTagBindings (ctx , pTest .ID , WorkspaceAddTagBindingsOptions {
308
+ TagBindings : tagBindings ,
309
+ })
310
+ require .Error (t , err , "cannot exceed 10 bindings per resource" )
311
+ })
312
+ }
313
+
250
314
func TestProjectsDelete (t * testing.T ) {
251
315
client := testClient (t )
252
316
ctx := context .Background ()
0 commit comments