@@ -13,10 +13,6 @@ import (
1313 "github.com/stretchr/testify/assert"
1414)
1515
16- func ptr (value string ) * string {
17- return & value
18- }
19-
2016func createValidUser (dynamicAttribute string ) UserRepresentation {
2117 var (
2218 bFalse = false
@@ -34,8 +30,8 @@ func createValidUser(dynamicAttribute string) UserRepresentation {
3430 idDocExpiration = "23.02.2039"
3531 locale = "fr"
3632 businessID = "123456789"
37- accred1 = AccreditationRepresentation {Type : ptr ("short" ), ExpiryDate : ptr ("31.12.2024" )}
38- accred2 = AccreditationRepresentation {Type : ptr ("long" ), ExpiryDate : ptr ("31.12.2039" )}
33+ accred1 = AccreditationRepresentation {Type : new ("short "), ExpiryDate : new ("31.12 .2024 ")}
34+ accred2 = AccreditationRepresentation {Type : new ("long "), ExpiryDate : new ("31.12 .2039 ")}
3935 creds = []AccreditationRepresentation {accred1 , accred2 }
4036 attachments = []AttachmentRepresentation {createValidAttachment ()}
4137 dynamicValue = "customValue"
@@ -70,7 +66,7 @@ func createValidAttachment() AttachmentRepresentation {
7066 contentBase = "basicvalueofsomecharacters"
7167 contentBytes = []byte (contentBase + contentBase + contentBase + contentBase )
7268 )
73- return AttachmentRepresentation {Filename : ptr ("filename.pdf" ), ContentType : ptr ("application/pdf" ), Content : & contentBytes }
69+ return AttachmentRepresentation {Filename : new ("filename.pdf "), ContentType : new ("application / pdf "), Content : & contentBytes }
7470}
7571
7672func createValidKeycloakUser (dynamicAttribute string ) kc.UserRepresentation {
@@ -231,7 +227,7 @@ func TestValidateUserRepresentation(t *testing.T) {
231227 t .Run ("Valid users with max attachments" , func (t * testing.T ) {
232228 var user = createValidUser ("" )
233229 var attachment []AttachmentRepresentation
234- for i := 0 ; i < maxNumberAttachments ; i ++ {
230+ for range maxNumberAttachments {
235231 attachment = append (attachment , createValidAttachment ())
236232 }
237233 user .Attachments = & attachment
@@ -240,7 +236,7 @@ func TestValidateUserRepresentation(t *testing.T) {
240236 t .Run ("Valid users with too many attachments" , func (t * testing.T ) {
241237 var user = createValidUser ("" )
242238 var attachment []AttachmentRepresentation
243- for i := 0 ; i < maxNumberAttachments + 1 ; i ++ {
239+ for range maxNumberAttachments + 1 {
244240 attachment = append (attachment , createValidAttachment ())
245241 }
246242 user .Attachments = & attachment
@@ -271,7 +267,7 @@ func TestGetSetField(t *testing.T) {
271267 assert .Nil (t , user .GetField ("not-existing-field" ))
272268}
273269
274- func testGetSetField (t * testing.T , fieldName string , value interface {} ) {
270+ func testGetSetField (t * testing.T , fieldName string , value any ) {
275271 var user UserRepresentation
276272 t .Run ("Field " + fieldName , func (t * testing.T ) {
277273 assert .Nil (t , user .GetField (fieldName ))
@@ -287,7 +283,7 @@ func TestValidateAttachment(t *testing.T) {
287283 })
288284 t .Run ("Successful evaluation of content type" , func (t * testing.T ) {
289285 var attachment = createValidAttachment ()
290- attachment .Filename = ptr ("image.JPG" )
286+ attachment .Filename = new ("image.JPG ")
291287 attachment .ContentType = nil
292288 assert .Nil (t , attachment .Validate ())
293289 assert .Equal (t , "image/jpeg" , * attachment .ContentType )
@@ -300,19 +296,19 @@ func TestValidateAttachment(t *testing.T) {
300296 })
301297 t .Run ("Invalid content type" , func (t * testing.T ) {
302298 var attachment = createValidAttachment ()
303- attachment .ContentType = ptr ("not-a-valid-content-type" )
299+ attachment .ContentType = new ("not - a - valid - content - type ")
304300 assert .NotNil (t , attachment .Validate ())
305301 })
306302 t .Run ("Can't find known content type from filename" , func (t * testing.T ) {
307303 var attachment = createValidAttachment ()
308- attachment .Filename = ptr ("image.gif" )
304+ attachment .Filename = new ("image.gif ")
309305 attachment .ContentType = nil
310306 assert .NotNil (t , attachment .Validate ())
311307 })
312308 t .Run ("Unsupported content type" , func (t * testing.T ) {
313309 var attachment = createValidAttachment ()
314310 attachment .Filename = nil
315- attachment .ContentType = ptr ("text/plain" )
311+ attachment .ContentType = new ("text / plain ")
316312 assert .NotNil (t , attachment .Validate ())
317313 })
318314 t .Run ("Invalid content length" , func (t * testing.T ) {
0 commit comments