Make failure message on unexpected extract helpful

This commit is contained in:
Jeroen Engels 2022-12-01 22:20:13 +01:00
parent 83f51e00ad
commit e1766bad01
3 changed files with 10 additions and 6 deletions

View File

@ -1576,8 +1576,8 @@ expectConfigurationErrorDetailsMatch expectedError configurationError =
expectNoDataExtract : ExtractResult -> Expectation
expectNoDataExtract maybeExtract =
case maybeExtract of
Just _ ->
Expect.fail FailureMessage.needToUsedExpectErrorsForModules
Just extract ->
Expect.fail (FailureMessage.unexpectedExtract extract)
Nothing ->
Expect.pass

View File

@ -653,9 +653,11 @@ but I could not find it.""")
unexpectedExtract : Encode.Value -> String
unexpectedExtract value =
failureMessage "UNEXPECTED EXTRACT"
("""This rule returned an extract which I did not expect.
("""This rule returned an extract but I did not expect one.
You should use `REPLACEME` to assert that the extract fits what you had.
You should use `Review.Test.expectDataExtract` or
`Review.Test.expect`+`Review.Test.dataExtract` to assert that the extract
fits what you expected.
""" ++ formatJson value)

View File

@ -1180,9 +1180,11 @@ unexpectedExtractTest =
|> expectMessageEqual """
\u{001B}[31m\u{001B}[1mUNEXPECTED EXTRACT\u{001B}[22m\u{001B}[39m
This rule returned an extract which I did not expect.
This rule returned an extract but I did not expect one.
You should use `REPLACEME` to assert that the extract fits what you had.
You should use `Review.Test.expectDataExtract` or
`Review.Test.expect`+`Review.Test.dataExtract` to assert that the extract
fits what you expected.
{
"foo": "bar",