Skip to content

Commit

Permalink
Fix escaping test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-yevsyukov committed Nov 17, 2023
1 parent f98e5fe commit 8b8eec8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.google.protobuf.StringValue;
import io.spine.test.validate.AllThePatterns;
import io.spine.test.validate.PatternStringFieldValue;
import io.spine.validate.Diags;
import io.spine.validate.NonValidated;
import io.spine.validate.ValidationOfConstraintTest;
import org.checkerframework.checker.regex.qual.Regex;
Expand Down Expand Up @@ -68,9 +67,10 @@ void considerFieldIsValidIfNoPatternOptionSet() {
@DisplayName("provide one valid violation if string does not match to regex pattern")
void provideOneValidViolationIfStringDoesNotMatchToRegexPattern() {
var msg = patternStringFor("invalid email");
@Regex
String regex = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
var expectedErrMsg = errorMessage(regex);
@Regex // As defined in the stub message type `PatternStringFieldValue`.
String regex =
"^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
var expectedErrMsg = errorMessage(regex).replace("\\\\", "\\");
assertSingleViolation(msg, expectedErrMsg, EMAIL);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ package io.spine.validate

import com.google.common.truth.Truth.assertThat
import com.google.protobuf.Message
import io.kotest.matchers.collections.shouldBeEmpty
import io.kotest.matchers.collections.shouldHaveSize
import io.kotest.matchers.shouldBe
import io.spine.validate.Validate.violationsOf
Expand Down Expand Up @@ -136,7 +137,7 @@ abstract class ValidationOfConstraintTest {
)
actualErrorMessage shouldBe expectedErrMsg
assertFieldPathIs(violation, invalidFieldName)
assertThat(violation.violationList).isEmpty()
violation.violationList.shouldBeEmpty()
}

protected fun assertSingleViolation(message: Message, invalidFieldName: String) {
Expand Down

0 comments on commit 8b8eec8

Please sign in to comment.