Skip to content

Commit

Permalink
Mock TimeoutException for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anotheroneofthese committed Aug 13, 2024
1 parent 9d2dc4e commit a23abd1
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.springframework.web.server.ServerErrorException
import org.springframework.web.server.ServerWebInputException
import reactor.core.publisher.Mono
import java.net.URI
import java.util.concurrent.TimeoutException

@TestInstance(PER_CLASS)
@ExtendWith(MockKExtension::class)
Expand Down Expand Up @@ -98,7 +99,7 @@ class ProductServiceTest {
@Suppress("ReactiveStreamsUnusedPublisher")
@Test
fun `save when DB fails handles it gracefully`() {
every { db.findByHostNameAndHostId(tpp.hostName, tpp.hostId) } returns Mono.never()
every { db.findByHostNameAndHostId(tpp.hostName, tpp.hostId) } returns Mono.error(TimeoutException())
every { synq.createProduct(any()) } returns ResponseEntity.created(URI.create("")).build()
every { db.save(any()) } returns Mono.error(Exception("DB is down"))

Expand Down

0 comments on commit a23abd1

Please sign in to comment.