I have the following haskell test code with which I want to test my argument parser for a script.
error' = let mp = runParser AllowOpts globalOptsParser ["-d", "billing"]
opts = ParserPrefs "suffix" False False False 80
in fst $ runP mp opts
The required arguments are,
-d <DB name>
--sql <SQL SELECT statement>
--descr <Description>
--file-path </path/to/file>
I want to test that I get the error message,
Missing: --sql <SQL SELECT statement> --descr <Description>
--file-path </path/to/file>
when I only specify "-d billing".
The above test code gives the following output if I print the result,
Left (MissingError (MultNode [MultNode [MultNode [AltNode [Leaf (Chunk {unChunk = Just --sql <SQL SELECT statement>}),MultNode []]],AltNode [Leaf (Chunk {unChunk = Just --descr <Description>}),MultNode []]],AltNode [Leaf (Chunk {unChunk = Just --file-path </path/to/file>}),MultNode []]]))
Is there a way to generate the expected error message (String) from the above result (Either data type)? Does Haskell provide an obvious function to use for this purpose as I cannot find something in the documentation and googling for examples also didn't produce any answers.
Aucun commentaire:
Enregistrer un commentaire