Skip to content

Commit

Permalink
Fixed WriteCheckpointRepositoryUnitTests
Browse files Browse the repository at this point in the history
  • Loading branch information
TebaleloS committed Jul 26, 2024
1 parent d684420 commit 1908297
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object CheckpointRepositoryUnitTests extends ZIOSpecDefault with TestData {

when(writeCheckpointMock.apply(checkpointDTO1)).thenReturn(ZIO.right(Row(FunctionStatus(0, "success"), ())))
when(writeCheckpointMock.apply(checkpointDTO2))
.thenReturn(ZIO.left(ErrorInDataException(FunctionStatus(50, "error in data"))))
.thenReturn(ZIO.fail(DatabaseError("Operation 'writeCheckpoint' failed with unexpected error: null")))
when(writeCheckpointMock.apply(checkpointDTO3)).thenReturn(ZIO.fail(new Exception("boom!")))

private val writeCheckpointMockLayer = ZLayer.succeed(writeCheckpointMock)
Expand All @@ -47,12 +47,12 @@ object CheckpointRepositoryUnitTests extends ZIOSpecDefault with TestData {
test("Returns expected Right with Unit") {
for {
result <- CheckpointRepository.writeCheckpoint(checkpointDTO1)
} yield assert(result)(isUnit)
} yield assertTrue(result == ())
},
test("Returns expected Left with StatusException") {
for {
result <- CheckpointRepository.writeCheckpoint(checkpointDTO2)
} yield assert(result)(isUnit)
result <- CheckpointRepository.writeCheckpoint(checkpointDTO2).exit
} yield assertTrue(result == Exit.fail(DatabaseError("Operation 'writeCheckpoint' failed with unexpected error: null")))
},
test("Returns expected DatabaseError") {
assertZIO(CheckpointRepository.writeCheckpoint(checkpointDTO3).exit)(failsWithA[DatabaseError])
Expand Down

0 comments on commit 1908297

Please sign in to comment.