Skip to content

Commit

Permalink
Standardize error messages a little more.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamirTalwar committed Aug 6, 2022
1 parent 729c64c commit 857a5a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions spec/malformed-specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ tests:
stderr:
- |
The test specification "fixtures/malformed-specs/wrong-type.yaml" is invalid:
Error in $.tests[0].stdout[0]: expected contents, but encountered Number
Error in $.tests[0].stdout[0]: expected "contents" or a "file", but encountered Number
- |
The test specification "fixtures\malformed-specs\wrong-type.yaml" is invalid:
Error in $.tests[0].stdout[0]: expected contents, but encountered Number
Error in $.tests[0].stdout[0]: expected "contents" or a "file", but encountered Number
- name: unknown-matcher
args:
Expand All @@ -58,7 +58,7 @@ tests:
stderr:
- |
The test specification "fixtures/malformed-specs/unknown-matcher.yaml" is invalid:
Error in $.tests[0].stdout: Expected "contents" or a "file".
Error in $.tests[0].stdout: Expected "contents" or a "file"
- |
The test specification "fixtures\malformed-specs\unknown-matcher.yaml" is invalid:
Error in $.tests[0].stdout: Expected "contents" or a "file".
Error in $.tests[0].stdout: Expected "contents" or a "file"
6 changes: 3 additions & 3 deletions src/lib/Test/Smoke/Types/Values.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ instance (FixtureType a, FromJSON a) => FromJSON (Contents a) where
maybeContents <- v .:? "contents"
maybeFile <- v .:? "file"
case (maybeContents, maybeFile) of
(Just _, Just _) -> fail "Expected \"contents\" or a \"file\", not both."
(Just _, Just _) -> fail "Expected \"contents\" or a \"file\", not both"
(Just contents, Nothing) -> Inline <$> parseJSON contents
(Nothing, Just file) -> return $ FileLocation file
(Nothing, Nothing) -> fail "Expected \"contents\" or a \"file\"."
parseJSON invalid = typeMismatch "contents" invalid
(Nothing, Nothing) -> fail "Expected \"contents\" or a \"file\""
parseJSON invalid = typeMismatch "\"contents\" or a \"file\"" invalid

data TestInput a where
TestInput :: Contents a -> TestInput a
Expand Down

0 comments on commit 857a5a2

Please sign in to comment.