Make Review.Test.expectConfigurationError work without run* functions

This commit is contained in:
Jeroen Engels 2021-03-10 08:44:19 +01:00
parent d8de5557f1
commit 25cad184d0
2 changed files with 9 additions and 18 deletions

View File

@ -1464,16 +1464,13 @@ extractExpectedErrorData ((ExpectedError expectedErrorContent) as expectedError)
}
expectConfigurationError : { message : String, details : List String } -> ReviewResult -> Expectation
expectConfigurationError expectedError reviewResult =
case reviewResult of
ConfigurationError configurationError ->
expectConfigurationError : { message : String, details : List String } -> Rule -> Expectation
expectConfigurationError expectedError rule =
case Rule.getConfigurationError rule of
Just configurationError ->
expectConfigurationErrorDetailsMatch expectedError configurationError
FailedRun _ ->
Expect.fail (FailureMessage.missingConfigurationError expectedError.message)
SuccessfulRun _ _ ->
Nothing ->
Expect.fail (FailureMessage.missingConfigurationError expectedError.message)

View File

@ -223,16 +223,10 @@ a = Regex.fromString "(abc|"
]
, test "should report a configuration error when module name is invalid" <|
\_ ->
"""module A exposing (..)
import SomeModule.Regex
a = SomeModule.Regex.fromLiteralFunc "^abc$"
"""
|> Review.Test.runWithProjectData project
(rule
{ unsafeFunction = "invalid name"
, moduleAlias = Nothing
}
)
rule
{ unsafeFunction = "invalid name"
, moduleAlias = Nothing
}
|> Review.Test.expectConfigurationError
{ message = "invalid name is not a valid function name"
, details = [ "Some details" ]