test: Add basic doctests for pFieldName
Signed-off-by: Wolfgang Walther <walther@technowledgy.de>
This commit is contained in:
committed by
Wolfgang Walther
parent
8c0d187044
commit
ecf54bef43
@@ -328,11 +328,39 @@ pFieldForest = pFieldTree `sepBy1` lexeme (char ',')
|
|||||||
pStar :: Parser Text
|
pStar :: Parser Text
|
||||||
pStar = string "*" $> "*"
|
pStar = string "*" $> "*"
|
||||||
|
|
||||||
|
-- |
|
||||||
|
-- Parse field names
|
||||||
|
--
|
||||||
|
-- >>> P.parse pFieldName "" "identifier"
|
||||||
|
-- Right "identifier"
|
||||||
|
--
|
||||||
|
-- >>> P.parse pFieldName "" "identifier with spaces"
|
||||||
|
-- Right "identifier with spaces"
|
||||||
|
--
|
||||||
|
-- >>> P.parse pFieldName "" "identifier-with-dashes"
|
||||||
|
-- Right "identifier-with-dashes"
|
||||||
|
--
|
||||||
|
-- >>> P.parse pFieldName "" "123"
|
||||||
|
-- Right "123"
|
||||||
|
--
|
||||||
|
-- >>> P.parse pFieldName "" "_"
|
||||||
|
-- Right "_"
|
||||||
|
--
|
||||||
|
-- >>> P.parse pFieldName "" "$"
|
||||||
|
-- Right "$"
|
||||||
|
--
|
||||||
|
-- >>> P.parse pFieldName "" ":"
|
||||||
|
-- Left (line 1, column 1):
|
||||||
|
-- unexpected ":"
|
||||||
|
-- expecting field name (* or [a..z0..9_ $])
|
||||||
|
--
|
||||||
|
-- >>> P.parse pFieldName "" "\":\""
|
||||||
|
-- Right ":"
|
||||||
pFieldName :: Parser Text
|
pFieldName :: Parser Text
|
||||||
pFieldName =
|
pFieldName =
|
||||||
pQuotedValue <|>
|
pQuotedValue <|>
|
||||||
T.intercalate "-" . map toS <$> (many1 pIdentifierChar `sepBy1` dash) <?>
|
T.intercalate "-" . map toS <$> (many1 pIdentifierChar `sepBy1` dash) <?>
|
||||||
"field name (* or [a..z0..9_])"
|
"field name (* or [a..z0..9_ $])"
|
||||||
where
|
where
|
||||||
isDash :: GenParser Char st ()
|
isDash :: GenParser Char st ()
|
||||||
isDash = try ( char '-' >> notFollowedBy (char '>') )
|
isDash = try ( char '-' >> notFollowedBy (char '>') )
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ spec actualPgVersion =
|
|||||||
it "cannot have zero conditions" $
|
it "cannot have zero conditions" $
|
||||||
get "/entities?or=()" `shouldRespondWith`
|
get "/entities?or=()" `shouldRespondWith`
|
||||||
[json|{
|
[json|{
|
||||||
"details": "unexpected \")\" expecting field name (* or [a..z0..9_]), negation operator (not) or logic operator (and, or)",
|
"details": "unexpected \")\" expecting field name (* or [a..z0..9_ $]), negation operator (not) or logic operator (and, or)",
|
||||||
"message": "\"failed to parse logic tree (())\" (line 1, column 4)",
|
"message": "\"failed to parse logic tree (())\" (line 1, column 4)",
|
||||||
"code": "PGRST100",
|
"code": "PGRST100",
|
||||||
"hint": null
|
"hint": null
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ spec actualPgVersion = do
|
|||||||
{"id": 204, "body": "yyy"},
|
{"id": 204, "body": "yyy"},
|
||||||
{"id": 205, "body": "zzz"}]|]
|
{"id": 205, "body": "zzz"}]|]
|
||||||
`shouldRespondWith`
|
`shouldRespondWith`
|
||||||
[json| {"details":"unexpected end of input expecting field name (* or [a..z0..9_])","message":"\"failed to parse columns parameter ()\" (line 1, column 1)","code":"PGRST100","hint":null} |]
|
[json| {"details":"unexpected end of input expecting field name (* or [a..z0..9_ $])","message":"\"failed to parse columns parameter ()\" (line 1, column 1)","code":"PGRST100","hint":null} |]
|
||||||
{ matchStatus = 400
|
{ matchStatus = 400
|
||||||
, matchHeaders = []
|
, matchHeaders = []
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user