Skip to content

Commit

Permalink
Add test for not found case
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelreiswildlife committed Jun 28, 2024
1 parent 2136d07 commit e1af2f4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions internal/core/operations/rooms/remove/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"context"
"errors"
"fmt"
porterrors "github.com/topfreegames/maestro/internal/core/ports/errors"

Check failure on line 32 in internal/core/operations/rooms/remove/executor_test.go

View workflow job for this annotation

GitHub Actions / Run linters

File is not `goimports`-ed (goimports)
"testing"

serviceerrors "github.com/topfreegames/maestro/internal/core/services/errors"
Expand Down Expand Up @@ -202,6 +203,32 @@ func TestExecutor_Execute(t *testing.T) {
require.ErrorContains(t, err, "error removing rooms by ids: error on remove room")
})

t.Run("when any room returns not found on delete it is ignored and returns without error", func(t *testing.T) {
executor, _, roomsManager, operationManager := testSetup(t)

firstRoomID := "first-room-id"
secondRoomID := "second-room-id"

schedulerName := uuid.NewString()
definition := &Definition{RoomsIDs: []string{firstRoomID, secondRoomID}}
op := &operation.Operation{ID: "random-uuid", SchedulerName: schedulerName}

room := &game_room.GameRoom{
ID: firstRoomID,
SchedulerID: schedulerName,
}
secondRoom := &game_room.GameRoom{
ID: secondRoomID,
SchedulerID: schedulerName,
}
roomsManager.EXPECT().DeleteRoom(gomock.Any(), room).Return(nil)
roomsManager.EXPECT().DeleteRoom(gomock.Any(), secondRoom).Return(porterrors.NewErrNotFound("not found"))
operationManager.EXPECT().AppendOperationEventToExecutionHistory(gomock.Any(), op, gomock.Any())

err := executor.Execute(context.Background(), op, definition)
require.NoError(t, err)
})

t.Run("when any room failed to delete with timeout error it returns with error", func(t *testing.T) {
executor, _, roomsManager, operationManager := testSetup(t)

Expand Down

0 comments on commit e1af2f4

Please sign in to comment.