@@ -10,7 +10,6 @@ import (
1010 "time"
1111
1212 "github.com/google/uuid"
13- "github.com/stretchr/testify/assert"
1413 "github.com/stretchr/testify/require"
1514 "google.golang.org/protobuf/types/known/fieldmaskpb"
1615 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -119,8 +118,11 @@ func TestDataModelSanity(t *testing.T) {
119118 t .Run ("tenant exists and has desired_state eq CREATED" , func (t * testing.T ) {
120119 require .Eventuallyf (t , func () bool {
121120 tenant , e := ic .GetTenantResourceInstance (ctx , projectInfo .B )
121+ if e != nil {
122+ return false
123+ }
122124 expected := tenantv1 .TenantState_TENANT_STATE_CREATED
123- return e == nil && expected == tenant .GetDesiredState ()
125+ return expected == tenant .GetDesiredState ()
124126 }, eventuallyTimeout , eventuallyInterval ,
125127 "EXPECTED: tenant[%s] with current_state == created was expected" , projectInfo .B )
126128 })
@@ -135,8 +137,10 @@ func TestDataModelSanity(t *testing.T) {
135137 require .Eventuallyf (t ,
136138 func () bool {
137139 aw , e := getActiveWatcher (ctx , nxc , projectInfo .A )
138- return e == nil &&
139- assert .Equal (t , baseprojectactivewatcherinfrahostcomv1 .StatusIndicationIdle , aw .Spec .StatusIndicator )
140+ if e != nil {
141+ return false
142+ }
143+ return aw .Spec .StatusIndicator == baseprojectactivewatcherinfrahostcomv1 .StatusIndicationIdle
140144 },
141145 eventuallyTimeout ,
142146 eventuallyInterval ,
@@ -391,7 +395,7 @@ func assertActiveWatcherDoesNotExist(t *testing.T, nxc *nexus.Client, projectNam
391395 },
392396 eventuallyTimeout ,
393397 eventuallyInterval ,
394- "EXPECTED: ACTIVEWATCHER[%s] shall not exists " ,
398+ "EXPECTED: ACTIVEWATCHER[%s] shall not exist " ,
395399 configuration .AppName ,
396400 )
397401}
@@ -401,8 +405,11 @@ func assertActiveWatcherInProgress(t *testing.T, nxc *nexus.Client, projectName
401405 ctx := context .TODO ()
402406 require .Eventuallyf (t , func () bool {
403407 aw , e := getActiveWatcher (ctx , nxc , projectName )
408+ if e != nil {
409+ return false
410+ }
404411 expected := baseprojectactivewatcherinfrahostcomv1 .StatusIndicationInProgress
405- return e == nil && aw .Spec .StatusIndicator == expected
412+ return aw .Spec .StatusIndicator == expected
406413 },
407414 eventuallyTimeout ,
408415 eventuallyInterval ,
@@ -415,12 +422,15 @@ func assertActiveWatcherIdle(t *testing.T, nxc *nexus.Client, projectName string
415422 t .Helper ()
416423 require .Eventuallyf (t , func () bool {
417424 aw , e := getActiveWatcher (context .TODO (), nxc , projectName )
425+ if e != nil {
426+ return false
427+ }
418428 expected := baseprojectactivewatcherinfrahostcomv1 .StatusIndicationIdle
419- return e == nil && aw .Spec .StatusIndicator == expected
429+ return aw .Spec .StatusIndicator == expected
420430 },
421431 eventuallyTimeout ,
422432 eventuallyInterval ,
423- "EXPECTED: ACTIVEWATCHER[%s] statusIndicator == IN_PROGRESS " ,
433+ "EXPECTED: ACTIVEWATCHER[%s] statusIndicator == IDLE " ,
424434 configuration .AppName ,
425435 )
426436}
@@ -429,19 +439,27 @@ func assertTenantExistsCurrentStateCreated(t *testing.T, ic *invclient.TCInvento
429439 t .Helper ()
430440 require .Eventuallyf (t , func () bool {
431441 tid , rid , err := ic .GetTenantResource (context .TODO (), projectID )
432- assert .NoError (t , err )
442+ if err != nil {
443+ return false
444+ }
433445 rsp , e := ic .Get (context .TODO (), tid , rid )
446+ if e != nil {
447+ return false
448+ }
434449 expected := tenantv1 .TenantState_TENANT_STATE_CREATED
435- return e == nil && expected == rsp .GetResource ().GetTenant ().GetCurrentState ()
450+ return expected == rsp .GetResource ().GetTenant ().GetCurrentState ()
436451 }, eventuallyTimeout , eventuallyInterval , "EXPECTED: tenant[%s] with current_state == created was expected" , projectID )
437452}
438453
439454func assertTenantExistsDesiredStateCreated (t * testing.T , ic * invclient.TCInventoryClient , projectID string ) {
440455 t .Helper ()
441456 require .Eventuallyf (t , func () bool {
442457 tenant , e := ic .GetTenantResourceInstance (context .TODO (), projectID )
458+ if e != nil {
459+ return false
460+ }
443461 expected := tenantv1 .TenantState_TENANT_STATE_CREATED
444- return e == nil && expected == tenant .GetDesiredState ()
462+ return expected == tenant .GetDesiredState ()
445463 }, eventuallyTimeout , eventuallyInterval ,
446464 "EXPECTED: tenant[%s] with current_state == created was expected" , projectID )
447465}
@@ -474,7 +492,9 @@ func assertHostDesiredStateEqDeleted(t *testing.T, ic *invclient.TCInventoryClie
474492 Resource : & inv_v1.Resource {Resource : & inv_v1.Resource_Host {}},
475493 Filter : filters .NewBuilderWith (filters .ValEq ("tenant_id" , projectID )).Build (),
476494 })
477- require .NoError (t , err )
495+ if err != nil {
496+ return false
497+ }
478498 for _ , instance := range all {
479499 if instance .GetHost ().DesiredState != computev1 .HostState_HOST_STATE_DELETED {
480500 return false
@@ -491,7 +511,9 @@ func assertInstancesDesiredStateEqDeleted(t *testing.T, ic *invclient.TCInventor
491511 Resource : & inv_v1.Resource {Resource : & inv_v1.Resource_Instance {}},
492512 Filter : filters .NewBuilderWith (filters .ValEq ("tenant_id" , projectID )).Build (),
493513 })
494- require .NoError (t , err )
514+ if err != nil {
515+ return false
516+ }
495517 for _ , instance := range all {
496518 if instance .GetInstance ().DesiredState != computev1 .InstanceState_INSTANCE_STATE_DELETED {
497519 return false
0 commit comments