Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KjellBerlin committed Sep 23, 2024
1 parent 389adde commit 039a69f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/test/kotlin/com/carbonara/core/slack/SlackServiceTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SlackServiceTests {
OrderStatusUpdateScenario("delivered", OrderStatus.DELIVERED),
OrderStatusUpdateScenario("cancelled", OrderStatus.CANCELLED)
).map { scenario ->
DynamicTest.dynamicTest("Happy case for order status update with status ${scenario.orderType}") {
DynamicTest.dynamicTest("Happy case for order status update with status ${scenario.orderStatus}") {
val orderDao = createOrderDao(orderStatus = scenario.expectedOrderStatus)
val slackMessageParams = SlackMessageParams(
customerName = orderDao.userName,
Expand All @@ -40,14 +40,20 @@ class SlackServiceTests {
googleMapsLink = orderDao.deliveryAddress.createGoogleMapsLink(),
productNames = orderDao.products.map { it.productName },
orderStatus = scenario.expectedOrderStatus,
timeStamp = "1726842841"
timeStamp = "1726842841",
userName = "sherlock.holmes"
)

coEvery { orderService.updateOrderStatus(any(), any()) } returns orderDao
coEvery { slackMessageService.updateOrderMessage(any()) } returns Unit

runBlocking {
slackService.handleOrderStatusUpdate(orderDao.orderId.toString(), scenario.orderType, "1726842841")
slackService.handleOrderStatusUpdate(
orderId = orderDao.orderId.toString(),
slackOrderStatus = scenario.orderStatus,
messageTimestamp = "1726842841",
userName = "sherlock.holmes"
)
}

coVerify { orderService.updateOrderStatus(orderDao.orderId.toString(), scenario.expectedOrderStatus) }
Expand All @@ -57,6 +63,6 @@ class SlackServiceTests {
}

data class OrderStatusUpdateScenario(
val orderType: String,
val orderStatus: String,
val expectedOrderStatus: OrderStatus
)

0 comments on commit 039a69f

Please sign in to comment.