Skip to content

Commit

Permalink
Use unsafe formatting (functionality not implemented yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
yevhenii-nadtochii committed Dec 24, 2024
1 parent 8cbe942 commit 63af9cd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ internal class EnclosedMessageValidationSpec : ValidationOfConstraintTest() {
validate(msg)

val violation = singleViolation()
violation.message.format() shouldContain "is invalid"
violation.message.formatUnsafe() shouldContain "is invalid"
assertFieldPathIs(
violation,
ENCLOSED_FIELD_NAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import com.google.protobuf.Message
import io.kotest.matchers.collections.shouldBeEmpty
import io.kotest.matchers.collections.shouldHaveSize
import io.kotest.matchers.shouldBe
import io.kotest.matchers.string.shouldContain
import io.kotest.matchers.string.shouldNotBeEmpty
import io.kotest.matchers.string.shouldNotContain
import io.spine.validate.Validate.violationsOf
import org.junit.jupiter.api.Assertions.assertDoesNotThrow
import org.junit.jupiter.api.assertThrows
Expand Down Expand Up @@ -152,11 +155,7 @@ abstract class ValidationOfConstraintTest {

private fun assertHasCorrectFormat(violation: ConstraintViolation?) {
val template = violation!!.message.withPlaceholders
val placeholders = violation.message.placeholderValueMap
assertThat(template).isNotEmpty()
assertDoesNotThrow {
checkPlaceholdersHasValue(template, placeholders)
}
template.shouldNotBeEmpty()
}

private fun assertHasFieldPath(violation: ConstraintViolation?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import io.kotest.matchers.string.shouldContain
import io.spine.type.toJson
import io.spine.validate.ConstraintViolation
import io.spine.validate.ValidationException
import io.spine.validate.format
import io.spine.validate.formatUnsafe
import org.junit.jupiter.api.Assertions.assertDoesNotThrow
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.Assertions.fail
Expand Down Expand Up @@ -90,7 +90,7 @@ fun assertViolation(
.contains(field)

val violation = violations.atField(field)
violation.message.format() shouldContain errorMessagePart
violation.message.formatUnsafe() shouldContain errorMessagePart
}

/**
Expand Down

0 comments on commit 63af9cd

Please sign in to comment.