Skip to content

Commit

Permalink
refactor(test): simplify assert function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
torives committed Jan 17, 2024
1 parent cd57ea9 commit 8be7951
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/services/supervisor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (s *SupervisorServiceSuite) TestItStopsAllServicesWhenContextIsCanceled() {

select {
case err := <-result:
s.Assert().ErrorIs(err, context.Canceled)
s.ErrorIs(err, context.Canceled)
for _, service := range services {
mockService := service.(*MockService)
mockService.AssertExpectations(s.T())
Expand Down Expand Up @@ -158,7 +158,7 @@ func (s *SupervisorServiceSuite) TestItStopsAllServicesIfAServiceStops() {

select {
case err := <-result:
s.Assert().ErrorIs(err, mockErr)
s.ErrorIs(err, mockErr)
for _, service := range services {
mockService := service.(*MockService)
mockService.AssertExpectations(s.T())
Expand Down Expand Up @@ -204,7 +204,7 @@ func (s *SupervisorServiceSuite) TestItStopsCreatingServicesIfAServiceFailsToSta

select {
case err := <-result:
s.Assert().ErrorIs(err, mockErr)
s.ErrorIs(err, mockErr)
last := services[len(services)-1].(*MockService)
last.AssertNotCalled(s.T(), "Start", mock.Anything, mock.Anything)
case <-time.After(DefaultServiceTimeout):
Expand Down Expand Up @@ -252,7 +252,7 @@ func (s *SupervisorServiceSuite) TestItStopsCreatingServicesIfContextIsCanceled(

select {
case err := <-result:
s.Assert().ErrorIs(err, context.Canceled)
s.ErrorIs(err, context.Canceled)
for idx, service := range services {
mockService := service.(*MockService)
if idx > 1 {
Expand Down Expand Up @@ -292,7 +292,7 @@ func (s *SupervisorServiceSuite) TestItTimesOutIfServiceTakesTooLongToBeReady()

select {
case err := <-result:
s.Assert().ErrorIs(err, ServiceTimeoutError)
s.ErrorIs(err, ServiceTimeoutError)
mock1.AssertCalled(s.T(), "Start", mock.Anything, mock.Anything)
case <-ready:
s.FailNow("supervisor shouldn't be ready")
Expand Down Expand Up @@ -328,7 +328,7 @@ func (s *SupervisorServiceSuite) TestItTimesOutIfServicesTakeTooLongToStop() {
cancel()

err := <-result
s.Assert().ErrorIs(err, SupervisorTimeoutError)
s.ErrorIs(err, SupervisorTimeoutError)
}

type MockService struct {
Expand Down

0 comments on commit 8be7951

Please sign in to comment.