Skip to content

Commit

Permalink
Add golden test for base command help
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Feb 4, 2025
1 parent d240c6b commit 4794bbf
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cardano-cli/test/cardano-cli-golden/Test/Golden/Help.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,18 @@ hprop_golden_HelpCmds =
[ "help"
]

let lines = Text.lines $ Text.pack help
let usages = List.filter (not . null) $ fmap extractCmd $ maybeToList . selectCmd =<< lines
let lines = Text.lines (Text.pack help)
let usages = [] : List.filter (not . null) (fmap extractCmd $ maybeToList . selectCmd =<< lines)

forM_ usages $ \usage -> do
H.noteShow_ usage
let expectedCmdHelpFp =
"test/cardano-cli-golden/files/golden/help" </> Text.unpack (Text.intercalate "_" usage) <> ".cli"
"test/cardano-cli-golden/files/golden" </> subPath usage

cmdHelp <- filterAnsi . third <$> H.execDetailCardanoCLI (fmap Text.unpack usage)

H.diffVsGoldenFile cmdHelp expectedCmdHelpFp
where
subPath :: [Text] -> FilePath
subPath [] = "base_help.cli"
subPath usage = "help" </> Text.unpack (Text.intercalate "_" usage) <> ".cli"
67 changes: 67 additions & 0 deletions cardano-cli/test/cardano-cli-golden/files/golden/base_help.cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
cardano-cli - General purpose command-line utility to interact with
cardano-node. Provides specific commands to manage keys, addresses, build &
submit transactions, certificates, etc.

Usage: cardano-cli
( address
| key
| node
| hash
| query
| legacy
| byron
| shelley
| allegra
| mary
| alonzo
| babbage
| conway
| latest
| debug commands
| version
| compatible
)

Available options:
--version Show the cardano-cli version
-h,--help Show this help text

Available commands:
address Payment address commands.
key Key utility commands.
node Node operation commands.
hash Compute the hash to pass to the various --*-hash
arguments of commands.
query Node query commands. Will query the local node whose
Unix domain socket is obtained from the
CARDANO_NODE_SOCKET_PATH environment variable.
legacy Legacy commands

Byron specific commands
byron Byron specific commands

Available commands:
shelley Shelley era commands - DEPRECATED - will be removed
in the future
allegra Allegra era commands - DEPRECATED - will be removed
in the future
mary Mary era commands - DEPRECATED - will be removed in
the future
alonzo Alonzo era commands - DEPRECATED - will be removed in
the future
babbage Babbage era commands - DEPRECATED - will be removed
in the future
conway Conway era commands
latest Latest era commands (Conway)

debug commands
debug Debug commands

Miscellaneous commands
help Show all help
version Show the cardano-cli version
ping Ping a cardano node either using node-to-node or node-to-client protocol. It negotiates a handshake and keeps sending keep alive messages.

Available commands:
compatible Limited backward compatible commands for testing
only.

0 comments on commit 4794bbf

Please sign in to comment.