@@ -719,7 +719,6 @@ func (s *ServiceTestSuite) TestCreate() {
719719
720720 s .Run ("should return appeals on success" , func () {
721721 h := newServiceTestHelper ()
722- defer h .assertExpectations (s .T ())
723722 resources := []* domain.Resource {
724723 {
725724 ID : "1" ,
@@ -1106,11 +1105,13 @@ func (s *ServiceTestSuite) TestCreate() {
11061105
11071106 s .Nil (actualError )
11081107 s .Equal (expectedResult , appeals )
1108+
1109+ time .Sleep (time .Millisecond )
1110+ h .assertExpectations (s .T ())
11091111 })
11101112
11111113 s .Run ("should return appeals on success with latest policy" , func () {
11121114 h := newServiceTestHelper ()
1113- defer h .assertExpectations (s .T ())
11141115 expDate := timeNow .Add (23 * time .Hour )
11151116
11161117 resources := []* domain.Resource {
@@ -1570,12 +1571,14 @@ func (s *ServiceTestSuite) TestCreate() {
15701571
15711572 s .Nil (actualError )
15721573 s .Equal (expectedResult , appeals )
1574+
1575+ time .Sleep (time .Millisecond )
1576+ h .assertExpectations (s .T ())
15731577 })
15741578
15751579 s .Run ("additional appeal creation" , func () {
15761580 s .Run ("should use the overridding policy" , func () {
15771581 h := newServiceTestHelper ()
1578- defer h .assertExpectations (s .T ())
15791582 input := & domain.Appeal {
15801583 ResourceID : uuid .New ().String (),
15811584@@ -1668,13 +1671,15 @@ func (s *ServiceTestSuite) TestCreate() {
16681671 s .NoError (err )
16691672 s .Equal ("test-approval" , input .Approvals [0 ].Name )
16701673 s .Equal (expectedPermissions , input .Permissions )
1674+
1675+ time .Sleep (time .Millisecond )
1676+ h .assertExpectations (s .T ())
16711677 })
16721678 })
16731679}
16741680
16751681func (s * ServiceTestSuite ) TestCreateAppeal__WithExistingAppealAndWithAutoApprovalSteps () {
16761682 h := newServiceTestHelper ()
1677- defer h .assertExpectations (s .T ())
16781683
16791684 appeal .TimeNow = func () time.Time {
16801685 return timeNow
@@ -1943,11 +1948,13 @@ func (s *ServiceTestSuite) TestCreateAppeal__WithExistingAppealAndWithAutoApprov
19431948
19441949 s .Nil (actualError )
19451950 s .Equal (expectedResult , appeals )
1951+
1952+ time .Sleep (time .Millisecond )
1953+ h .assertExpectations (s .T ())
19461954}
19471955
19481956func (s * ServiceTestSuite ) TestCreateAppeal__WithAdditionalAppeals () {
19491957 h := newServiceTestHelper ()
1950- defer h .assertExpectations (s .T ())
19511958 providerType := "test-provider-type"
19521959 providerURN := "test-provider-urn"
19531960 resourceType := "test-resource-type"
@@ -2138,6 +2145,9 @@ func (s *ServiceTestSuite) TestCreateAppeal__WithAdditionalAppeals() {
21382145 err := h .service .Create (context .Background (), appealsPayload )
21392146
21402147 s .NoError (err )
2148+
2149+ time .Sleep (time .Millisecond )
2150+ h .assertExpectations (s .T ())
21412151}
21422152
21432153func (s * ServiceTestSuite ) TestCreate__WithAppealMetadata () {
@@ -2705,7 +2715,6 @@ func (s *ServiceTestSuite) TestUpdateApproval() {
27052715
27062716 s .Run ("should terminate existing active grant if present" , func () {
27072717 h := newServiceTestHelper ()
2708- defer h .assertExpectations (s .T ())
27092718 action := domain.ApprovalAction {
27102719 AppealID : appealID ,
27112720 ApprovalName : "test-approval-step" ,
@@ -2772,6 +2781,9 @@ func (s *ServiceTestSuite) TestUpdateApproval() {
27722781 _ , actualError := h .service .UpdateApproval (context .Background (), action )
27732782
27742783 s .Nil (actualError )
2784+
2785+ time .Sleep (time .Millisecond )
2786+ h .assertExpectations (s .T ())
27752787 })
27762788
27772789 s .Run ("should return updated appeal on success" , func () {
@@ -3128,7 +3140,6 @@ func (s *ServiceTestSuite) TestUpdateApproval() {
31283140 for _ , tc := range testCases {
31293141 s .Run (tc .name , func () {
31303142 h := newServiceTestHelper ()
3131- defer h .assertExpectations (s .T ())
31323143
31333144 h .mockRepository .EXPECT ().
31343145 GetByID (h .ctxMatcher , validApprovalActionParam .AppealID ).
@@ -3171,10 +3182,12 @@ func (s *ServiceTestSuite) TestUpdateApproval() {
31713182 Return (nil ).Once ()
31723183
31733184 actualResult , actualError := h .service .UpdateApproval (context .Background (), tc .expectedApprovalAction )
3174-
31753185 s .NoError (actualError )
31763186 tc .expectedResult .Policy = actualResult .Policy
31773187 s .Equal (tc .expectedResult , actualResult )
3188+
3189+ time .Sleep (time .Millisecond )
3190+ h .assertExpectations (s .T ())
31783191 })
31793192 }
31803193 })
@@ -3305,8 +3318,6 @@ func (s *ServiceTestSuite) TestCancel() {
33053318
33063319func (s * ServiceTestSuite ) TestAddApprover () {
33073320 s .Run ("should return appeal on success" , func () {
3308- h := newServiceTestHelper ()
3309- defer h .assertExpectations (s .T ())
33103321 appealID := uuid .New ().String ()
33113322 approvalID := uuid .New ().String ()
33123323 approvalName := "test-approval-name"
@@ -3327,6 +3338,7 @@ func (s *ServiceTestSuite) TestAddApprover() {
33273338
33283339 for _ , tc := range testCases {
33293340 s .Run (tc .name , func () {
3341+ h := newServiceTestHelper ()
33303342 expectedAppeal := & domain.Appeal {
33313343 ID : appealID ,
33323344 Status : domain .AppealStatusPending ,
@@ -3369,10 +3381,10 @@ func (s *ServiceTestSuite) TestAddApprover() {
33693381 h .mockNotifier .EXPECT ().
33703382 Notify (h .ctxMatcher , mock .Anything ).
33713383 Run (func (ctx context.Context , notifications []domain.Notification ) {
3372- s . Len ( notifications , 1 )
3384+ assert . Equal ( s . T (), len ( notifications ) , 1 )
33733385 n := notifications [0 ]
3374- s .Equal (tc .newApprover , n .User )
3375- s .Equal (domain .NotificationTypeApproverNotification , n .Message .Type )
3386+ assert .Equal (s . T (), tc .newApprover , n .User )
3387+ assert .Equal (s . T (), domain .NotificationTypeApproverNotification , n .Message .Type )
33763388 }).
33773389 Return (nil ).Once ()
33783390
@@ -3381,6 +3393,8 @@ func (s *ServiceTestSuite) TestAddApprover() {
33813393 s .NoError (actualError )
33823394 s .Equal (expectedApproval , actualAppeal .Approvals [0 ])
33833395
3396+ time .Sleep (time .Millisecond )
3397+ h .assertExpectations (s .T ())
33843398 })
33853399 }
33863400 })
0 commit comments