@@ -105,57 +105,76 @@ func TestTeamTokens_CreateWithOptions_MultipleTokens(t *testing.T) {
105
105
t .Run ("with multiple tokens" , func (t * testing.T ) {
106
106
desc1 := fmt .Sprintf ("go-tfe-team-token-test-%s" , randomString (t ))
107
107
tt , err := client .TeamTokens .CreateWithOptions (ctx , tmTest .ID , TeamTokenCreateOptions {
108
- Description : desc1 ,
108
+ Description : & desc1 ,
109
109
})
110
110
require .NoError (t , err )
111
111
require .NotEmpty (t , tt .Token )
112
- require .Equal (t , tt .Description , desc1 )
112
+ require .NotNil (t , tt .Description )
113
+ require .Equal (t , * tt .Description , desc1 )
113
114
114
115
desc2 := fmt .Sprintf ("go-tfe-team-token-test-%s" , randomString (t ))
115
116
tt , err = client .TeamTokens .CreateWithOptions (ctx , tmTest .ID , TeamTokenCreateOptions {
116
- Description : desc2 ,
117
+ Description : & desc2 ,
117
118
})
118
119
require .NoError (t , err )
119
120
require .NotEmpty (t , tt .Token )
120
- require .Equal (t , tt .Description , desc2 )
121
+ require .NotNil (t , tt .Description )
122
+ require .Equal (t , * tt .Description , desc2 )
123
+
124
+ emptyString := ""
125
+ tt , err = client .TeamTokens .CreateWithOptions (ctx , tmTest .ID , TeamTokenCreateOptions {
126
+ Description : & emptyString ,
127
+ })
128
+ require .NoError (t , err )
129
+ require .NotEmpty (t , tt .Token )
130
+ require .NotNil (t , tt .Description )
131
+ require .Equal (t , * tt .Description , emptyString )
132
+
133
+ tt , err = client .TeamTokens .CreateWithOptions (ctx , tmTest .ID , TeamTokenCreateOptions {})
134
+ require .NoError (t , err )
135
+ require .NotEmpty (t , tt .Token )
136
+ require .Nil (t , tt .Description )
121
137
})
122
138
123
139
t .Run ("with an expiration date" , func (t * testing.T ) {
124
140
desc := fmt .Sprintf ("go-tfe-team-token-test-%s" , randomString (t ))
125
141
currentTime := time .Now ().UTC ().Truncate (time .Second )
126
142
oneDayLater := currentTime .Add (24 * time .Hour )
127
143
tt , err := client .TeamTokens .CreateWithOptions (ctx , tmTest .ID , TeamTokenCreateOptions {
128
- Description : desc ,
144
+ Description : & desc ,
129
145
ExpiredAt : & oneDayLater ,
130
146
})
131
147
require .NoError (t , err )
132
148
require .NotEmpty (t , tt .Token )
133
149
assert .Equal (t , tt .ExpiredAt , oneDayLater )
134
- require .Equal (t , tt .Description , desc )
150
+ require .NotNil (t , tt .Description )
151
+ require .Equal (t , * tt .Description , desc )
135
152
})
136
153
137
154
t .Run ("without an expiration date" , func (t * testing.T ) {
138
155
desc := fmt .Sprintf ("go-tfe-team-token-test-%s" , randomString (t ))
139
156
tt , err := client .TeamTokens .CreateWithOptions (ctx , tmTest .ID , TeamTokenCreateOptions {
140
- Description : desc ,
157
+ Description : & desc ,
141
158
})
142
159
require .NoError (t , err )
143
160
require .NotEmpty (t , tt .Token )
144
161
assert .Empty (t , tt .ExpiredAt )
145
- require .Equal (t , tt .Description , desc )
162
+ require .NotNil (t , tt .Description )
163
+ require .Equal (t , * tt .Description , desc )
146
164
})
147
165
148
166
t .Run ("when a token already exists with the same description" , func (t * testing.T ) {
149
167
desc := fmt .Sprintf ("go-tfe-team-token-test-%s" , randomString (t ))
150
168
tt , err := client .TeamTokens .CreateWithOptions (ctx , tmTest .ID , TeamTokenCreateOptions {
151
- Description : desc ,
169
+ Description : & desc ,
152
170
})
153
171
require .NoError (t , err )
154
172
require .NotEmpty (t , tt .Token )
155
- require .Equal (t , tt .Description , desc )
173
+ require .NotNil (t , tt .Description )
174
+ require .Equal (t , * tt .Description , desc )
156
175
157
176
tt , err = client .TeamTokens .CreateWithOptions (ctx , tmTest .ID , TeamTokenCreateOptions {
158
- Description : desc ,
177
+ Description : & desc ,
159
178
})
160
179
assert .Nil (t , tt )
161
180
assert .Equal (t , err , ErrInvalidDescriptionConflict )
@@ -234,7 +253,7 @@ func TestTeamTokensReadByID(t *testing.T) {
234
253
tt , err := client .TeamTokens .ReadByID (ctx , token .ID )
235
254
require .NoError (t , err )
236
255
require .NotEmpty (t , tt )
237
- assert .Empty (t , tt .Description )
256
+ assert .Nil (t , tt .Description )
238
257
assert .Equal (t , tt .ExpiredAt , oneDayLater )
239
258
require .NotEmpty (t , tt .Team )
240
259
assert .Equal (t , tt .Team .ID , tmTest .ID )
@@ -244,29 +263,31 @@ func TestTeamTokensReadByID(t *testing.T) {
244
263
skipUnlessBeta (t )
245
264
desc1 := fmt .Sprintf ("go-tfe-team-token-test-%s" , randomString (t ))
246
265
token , ttTestCleanup := createTeamTokenWithOptions (t , client , tmTest , TeamTokenCreateOptions {
247
- Description : desc1 ,
266
+ Description : & desc1 ,
248
267
})
249
268
t .Cleanup (ttTestCleanup )
250
269
251
270
tt , err := client .TeamTokens .ReadByID (ctx , token .ID )
252
271
require .NoError (t , err )
253
272
require .NotEmpty (t , tt )
254
- assert .Equal (t , tt .Description , desc1 )
273
+ require .NotNil (t , tt .Description )
274
+ assert .Equal (t , * tt .Description , desc1 )
255
275
assert .Empty (t , tt .ExpiredAt )
256
276
require .NotEmpty (t , tt .Team )
257
277
assert .Equal (t , tt .Team .ID , tmTest .ID )
258
278
259
279
desc2 := fmt .Sprintf ("go-tfe-team-token-test-%s" , randomString (t ))
260
280
tokenWithExpiration , ttTestCleanup2 := createTeamTokenWithOptions (t , client , tmTest , TeamTokenCreateOptions {
261
281
ExpiredAt : & oneDayLater ,
262
- Description : desc2 ,
282
+ Description : & desc2 ,
263
283
})
264
284
t .Cleanup (ttTestCleanup2 )
265
285
266
286
tt2 , err := client .TeamTokens .ReadByID (ctx , tokenWithExpiration .ID )
267
287
require .NoError (t , err )
268
288
require .NotEmpty (t , tt2 )
269
- assert .Equal (t , tt2 .Description , desc2 )
289
+ require .NotNil (t , tt2 .Description )
290
+ assert .Equal (t , * tt2 .Description , desc2 )
270
291
assert .Equal (t , tt2 .ExpiredAt , oneDayLater )
271
292
require .NotEmpty (t , tt .Team )
272
293
assert .Equal (t , tt .Team .ID , tmTest .ID )
@@ -319,12 +340,14 @@ func TestTeamTokensDeleteByID(t *testing.T) {
319
340
320
341
t .Run ("with multiple team tokens" , func (t * testing.T ) {
321
342
skipUnlessBeta (t )
343
+ desc1 := fmt .Sprintf ("go-tfe-team-token-test-%s" , randomString (t ))
322
344
token1 , _ := createTeamTokenWithOptions (t , client , tmTest , TeamTokenCreateOptions {
323
- Description : fmt . Sprintf ( "go-tfe-team-token-test-%s" , randomString ( t )) ,
345
+ Description : & desc1 ,
324
346
})
325
347
348
+ desc2 := fmt .Sprintf ("go-tfe-team-token-test-%s" , randomString (t ))
326
349
token2 , _ := createTeamTokenWithOptions (t , client , tmTest , TeamTokenCreateOptions {
327
- Description : fmt . Sprintf ( "go-tfe-team-token-test-%s" , randomString ( t )) ,
350
+ Description : & desc2 ,
328
351
})
329
352
330
353
err := client .TeamTokens .DeleteByID (ctx , token1 .ID )
0 commit comments