Skip to content

Commit

Permalink
Allows the FakeBackfilaClientServiceClient to respond based on the pa…
Browse files Browse the repository at this point in the history
…rtition.
  • Loading branch information
mpawliszyn committed Aug 16, 2021
1 parent d2e45ff commit e288e96
Show file tree
Hide file tree
Showing 4 changed files with 237 additions and 182 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
object Dependencies {
val apacheCommonsLang3 = "org.apache.commons:commons-lang3:3.11"
val assertj = "org.assertj:assertj-core:3.16.1"
val assertj = "org.assertj:assertj-core:3.20.2"
val awsDynamodb = "com.amazonaws:aws-java-sdk-dynamodb:1.11.774"
val flywayGradleBuildscriptDep = "gradle.plugin.com.boxfuse.client:flyway-release:5.0.2"
val guava = "com.google.guava:guava:30.0-jre"
Expand Down
26 changes: 26 additions & 0 deletions service/src/test/kotlin/app/cash/backfila/TestTools.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package app.cash.backfila

import app.cash.backfila.dashboard.UiEventLog
import app.cash.backfila.service.persistence.DbEventLog
import misk.MiskCaller
import misk.inject.keyOf
import misk.scope.ActionScope
import org.assertj.core.api.Assertions
import org.assertj.core.api.Condition
import org.assertj.core.api.SoftAssertions

fun <T> ActionScope.fakeCaller(
service: String? = null,
Expand All @@ -12,3 +17,24 @@ fun <T> ActionScope.fakeCaller(
return enter(mapOf(keyOf<MiskCaller>() to MiskCaller(service = service, user = user)))
.use { function() }
}

// For useful soft assertions without forgetting to call assertAll()
fun softAssert(assertions: SoftAssertions.() -> Unit) {
with(SoftAssertions()) {
assertions()
assertAll()
}
}

// Makes asserting on UiEventLog entries easy.
fun uiEventLogWith(
type: DbEventLog.Type,
user: String?,
message: String
): Condition<UiEventLog> {
return Assertions.allOf(
Condition({ it.type == type }, "uiEventLog.type"),
Condition({ it.user == user }, "uiEventLog.user"),
Condition({ it.message == message }, "uiEventLog.message")
)
}
Loading

0 comments on commit e288e96

Please sign in to comment.