@@ -53,8 +53,7 @@ func TestMain(m *testing.M) {
5353}
5454
5555func TestCRUD (t * testing.T ) {
56- tenantDS , err := New (slog .Default (), db , & v1.Tenant {})
57- require .NoError (t , err )
56+ tenantDS := New (slog .Default (), db , & v1.Tenant {})
5857 assert .NotNil (t , tenantDS , "Datastore must not be nil" )
5958 ctx := context .Background ()
6059 tcr := & v1.Tenant {
@@ -63,7 +62,7 @@ func TestCRUD(t *testing.T) {
6362 Description : "A very important Tenant" ,
6463 }
6564
66- err = tenantDS .Create (ctx , tcr )
65+ err : = tenantDS .Create (ctx , tcr )
6766 require .NoError (t , err )
6867 assert .NotNil (t , tcr )
6968 // specified id is persisted
@@ -134,8 +133,7 @@ func TestCRUD(t *testing.T) {
134133}
135134
136135func TestUpdateOptimisticLock (t * testing.T ) {
137- tenantDS , err := New (slog .Default (), db , & v1.Tenant {})
138- require .NoError (t , err )
136+ tenantDS := New (slog .Default (), db , & v1.Tenant {})
139137 assert .NotNil (t , tenantDS , "Datastore must not be nil" )
140138 ctx := context .Background ()
141139 tcr := & v1.Tenant {
@@ -144,7 +142,7 @@ func TestUpdateOptimisticLock(t *testing.T) {
144142 Description : "A very important Tenant" ,
145143 }
146144
147- err = tenantDS .Create (ctx , tcr )
145+ err : = tenantDS .Create (ctx , tcr )
148146 require .NoError (t , err )
149147 assert .NotNil (t , tcr )
150148 assert .Equal (t , int64 (0 ), tcr .Meta .Version )
@@ -180,8 +178,7 @@ func TestUpdateOptimisticLock(t *testing.T) {
180178
181179func TestCreate (t * testing.T ) {
182180 const t1 = "t1"
183- tenantDS , err := New (slog .Default (), db , & v1.Tenant {})
184- require .NoError (t , err )
181+ tenantDS := New (slog .Default (), db , & v1.Tenant {})
185182 assert .NotNil (t , tenantDS , "Datastore must not be nil" )
186183 ctx := context .Background ()
187184
@@ -191,7 +188,7 @@ func TestCreate(t *testing.T) {
191188 }
192189
193190 // meta is nil
194- err = tenantDS .Create (ctx , tcr1 )
191+ err : = tenantDS .Create (ctx , tcr1 )
195192 require .Error (t , err )
196193 require .EqualError (t , err , "create of type:tenant failed, meta is nil" )
197194
@@ -271,8 +268,7 @@ func TestCreate(t *testing.T) {
271268
272269func TestUpdate (t * testing.T ) {
273270 const t3 = "t3"
274- tenantDS , err := New (slog .Default (), db , & v1.Tenant {})
275- require .NoError (t , err )
271+ tenantDS := New (slog .Default (), db , & v1.Tenant {})
276272 assert .NotNil (t , tenantDS , "Datastore must not be nil" )
277273 ctx := context .Background ()
278274
@@ -281,7 +277,7 @@ func TestUpdate(t *testing.T) {
281277 Name : "ctenant" ,
282278 Description : "C Tenant" ,
283279 }
284- err = tenantDS .Update (ctx , tcr1 )
280+ err : = tenantDS .Update (ctx , tcr1 )
285281 require .Error (t , err )
286282 require .EqualError (t , err , "update of type:tenant failed, meta is nil" )
287283
@@ -344,33 +340,30 @@ func TestUpdate(t *testing.T) {
344340
345341//nolint:unparam
346342func checkHistoryCreated (ctx context.Context , t * testing.T , id string , name string , desc string ) {
347- tenantDS , err := New (slog .Default (), db , & v1.Tenant {})
348- require .NoError (t , err )
343+ tenantDS := New (slog .Default (), db , & v1.Tenant {})
349344 var tgrhc v1.Tenant
350- err = tenantDS .GetHistoryCreated (ctx , id , & tgrhc )
345+ err : = tenantDS .GetHistoryCreated (ctx , id , & tgrhc )
351346 require .NoError (t , err )
352347 assert .Equal (t , name , tgrhc .Name )
353348 assert .Equal (t , desc , tgrhc .GetDescription ())
354349}
355350
356351func checkHistory (ctx context.Context , t * testing.T , id string , tm time.Time , name string , desc string ) {
357- tenantDS , err := New (slog .Default (), db , & v1.Tenant {})
358- require .NoError (t , err )
352+ tenantDS := New (slog .Default (), db , & v1.Tenant {})
359353 var tgrh v1.Tenant
360- err = tenantDS .GetHistory (ctx , id , tm , & tgrh )
354+ err : = tenantDS .GetHistory (ctx , id , tm , & tgrh )
361355 require .NoError (t , err )
362356 assert .Equal (t , name , tgrh .Name )
363357 assert .Equal (t , desc , tgrh .GetDescription ())
364358}
365359
366360func TestGet (t * testing.T ) {
367361 const t4 = "t4"
368- tenantDS , err := New (slog .Default (), db , & v1.Tenant {})
369- require .NoError (t , err )
362+ tenantDS := New (slog .Default (), db , & v1.Tenant {})
370363 assert .NotNil (t , tenantDS , "Datastore must not be nil" )
371364 ctx := context .Background ()
372365 // unknown id
373- _ , err = tenantDS .Get (ctx , "unknown-id" )
366+ _ , err : = tenantDS .Get (ctx , "unknown-id" )
374367 require .Error (t , err )
375368 require .EqualError (t , err , "tenant with id:unknown-id not found sql: no rows in result set" )
376369
@@ -396,16 +389,15 @@ func TestGet(t *testing.T) {
396389
397390func TestGetHistory (t * testing.T ) {
398391 const t5 = "t5"
399- tenantDS , err := New (slog .Default (), db , & v1.Tenant {})
400- require .NoError (t , err )
392+ tenantDS := New (slog .Default (), db , & v1.Tenant {})
401393 assert .NotNil (t , tenantDS , "Datastore must not be nil" )
402394 ctx := context .Background ()
403395
404396 tsNow := time .Date (2020 , 4 , 30 , 18 , 0 , 0 , 0 , time .UTC )
405397
406398 // unknown id
407399 var tgr1 v1.Tenant
408- err = tenantDS .GetHistory (ctx , "unknown-id" , tsNow , & tgr1 )
400+ err : = tenantDS .GetHistory (ctx , "unknown-id" , tsNow , & tgr1 )
409401 require .Error (t , err )
410402 require .EqualError (t , err , "entity of type:tenant with predicate:[map[id:unknown-id] map[created_at:2020-04-30 18:00:00 +0000 UTC]] not found" )
411403
@@ -487,8 +479,7 @@ func TestGetHistory(t *testing.T) {
487479
488480func TestFind (t * testing.T ) {
489481 const t6 = "t6"
490- tenantDS , err := New (slog .Default (), db , & v1.Tenant {})
491- require .NoError (t , err )
482+ tenantDS := New (slog .Default (), db , & v1.Tenant {})
492483 assert .NotNil (t , tenantDS , "Datastore must not be nil" )
493484 ctx := context .Background ()
494485
@@ -498,7 +489,7 @@ func TestFind(t *testing.T) {
498489 Name : "ftenant" ,
499490 Description : "F Tenant" ,
500491 }
501- err = tenantDS .Create (ctx , tcr1 )
492+ err : = tenantDS .Create (ctx , tcr1 )
502493 require .NoError (t , err )
503494 assert .Equal (t , t6 , tcr1 .GetMeta ().GetId ())
504495 assert .Equal (t , "ftenant" , tcr1 .GetName ())
@@ -554,10 +545,9 @@ func TestFind(t *testing.T) {
554545}
555546
556547func TestFindWithPaging (t * testing.T ) {
557- tenantDS , err := New (slog .Default (), db , & v1.Tenant {})
548+ tenantDS := New (slog .Default (), db , & v1.Tenant {})
558549 // prevent side effects
559550 db .MustExec ("DELETE from tenants" )
560- require .NoError (t , err )
561551 assert .NotNil (t , tenantDS , "Datastore must not be nil" )
562552 ctx := context .Background ()
563553
@@ -595,16 +585,15 @@ func TestFindWithPaging(t *testing.T) {
595585
596586func TestDelete (t * testing.T ) {
597587 const t9 = "t9"
598- tenantDS , err := New (slog .Default (), db , & v1.Tenant {})
599- require .NoError (t , err )
588+ tenantDS := New (slog .Default (), db , & v1.Tenant {})
600589 assert .NotNil (t , tenantDS , "Datastore must not be nil" )
601590 ctx := context .Background ()
602591
603592 // unknown id
604593 tdr1 := & v1.Tenant {
605594 Meta : & v1.Meta {Id : "unknown-id" },
606595 }
607- err = tenantDS .Delete (ctx , tdr1 .Meta .Id )
596+ err : = tenantDS .Delete (ctx , tdr1 .Meta .Id )
608597 require .Error (t , err )
609598 require .EqualError (t , err , "tenant with id:unknown-id not found sql: no rows in result set" )
610599
@@ -642,16 +631,15 @@ func TestDeleteAll(t *testing.T) {
642631 t11 = "t11"
643632 t10 = "t10"
644633 )
645- tenantDS , err := New (slog .Default (), db , & v1.Tenant {})
646- require .NoError (t , err )
634+ tenantDS := New (slog .Default (), db , & v1.Tenant {})
647635 assert .NotNil (t , tenantDS , "Datastore must not be nil" )
648636 ctx := context .Background ()
649637
650638 // unknown id
651639 tdr1 := & v1.Tenant {
652640 Meta : & v1.Meta {Id : "unknown-id" },
653641 }
654- err = tenantDS .DeleteAll (ctx , tdr1 .Meta .Id )
642+ err : = tenantDS .DeleteAll (ctx , tdr1 .Meta .Id )
655643 require .Error (t , err )
656644 require .EqualError (t , err , "tenant with id:unknown-id not found sql: no rows in result set" )
657645
@@ -702,8 +690,7 @@ func TestDeleteAll(t *testing.T) {
702690}
703691
704692func TestAnnotationsAndLabels (t * testing.T ) {
705- tenantDS , err := New (slog .Default (), db , & v1.Tenant {})
706- require .NoError (t , err )
693+ tenantDS := New (slog .Default (), db , & v1.Tenant {})
707694 assert .NotNil (t , tenantDS , "Datastore must not be nil" )
708695 ctx := context .Background ()
709696 tcr := & v1.Tenant {
@@ -721,7 +708,7 @@ func TestAnnotationsAndLabels(t *testing.T) {
721708 Description : "A very important Tenant" ,
722709 }
723710
724- err = tenantDS .Create (ctx , tcr )
711+ err : = tenantDS .Create (ctx , tcr )
725712 require .NoError (t , err )
726713 assert .NotNil (t , tcr )
727714 assert .Equal (t , int64 (0 ), tcr .Meta .Version )
0 commit comments