Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- assertEqualModuloDesc :: (HasCallStack, MonadIO m, MonadTest m) => FilePath -> FilePath -> m ()
- assertHasKeys :: (HasCallStack, MonadTest m, MonadIO m) => [Text] -> FilePath -> m ()
- assertHasMappings :: (HasCallStack, MonadTest m, MonadIO m) => [(Text, Text)] -> FilePath -> m ()
- redactJsonFieldsInFile :: (MonadTest m, MonadIO m, HasCallStack) => Map Text Text -> FilePath -> FilePath -> m ()
Documentation
assertEqualModuloDesc Source #
:: (HasCallStack, MonadIO m, MonadTest m) | |
=> FilePath | The file of the first generated verification key |
-> FilePath | The file of the second generated verification key, i.e. the one generated by calling "key verification-key" |
-> m () |
assertEqualModuloDesc file1 file2
loads file1
and file2
from disk,
then it strips the field description
from the loaded content, and finally compare
the two values. The values must be equal, otherwise the test is failed.
Required, because command "key" "verification-key"
generates keys without descriptions.
Note that it would be better to write descriptions, see:
https://github.com/IntersectMBO/cardano-cli/issues/429#issuecomment-2003880575
assertHasKeys :: (HasCallStack, MonadTest m, MonadIO m) => [Text] -> FilePath -> m () Source #
assertHasKeys keys path
succeeds if path
is a file containing a JSON object
whose keys is a superset of keys
.
For example. if path
contains "{ "a":0, "b":1.0, "c": "foo"}"
,
hasKeys ["b", "a"] path
succeeds.
assertHasMappings :: (HasCallStack, MonadTest m, MonadIO m) => [(Text, Text)] -> FilePath -> m () Source #
assertHasMappings pairs path
succeeds if path
is a file containing a JSON object
whose mappings is a superset of pairs
.
For example, if path
contains "{ "a":"bar", "b":"buzz", "c":"foo"}"
,
assertHasMappings "[("b", "buzz"), ("a", "bar")] path
succeeds.
redactJsonFieldsInFile Source #
:: (MonadTest m, MonadIO m, HasCallStack) | |
=> Map Text Text | Map from key name, to the new (String) value to attach to this key |
-> FilePath | |
-> FilePath | |
-> m () |
redactJsonStringFieldInFile [(k0, v0), (k1, v1), ..] sourceFilePath targetFilePath
reads the JSON at sourceFilePath
, and then
replaces the value associated to k0
by v0
, replaces the value associated to k1
by v1
, etc.
Then the obtained JSON is written to targetFilePath
. This replacement is done recursively
so k0
, k1
, etc. can appear at any depth within the JSON.