diff options
author | Patrick Spek <p.spek@tyil.nl> | 2020-07-12 08:54:43 +0200 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2023-07-25 02:17:27 +0200 |
commit | 3672d9d82e522b73f2a8f45bc37459ee7b06750d (patch) | |
tree | 00772a675945ae42b77e29ed04a0abfe3593cb46 /lib/Config/Parser/NULL.rakumod | |
parent | 04bbe0524a9443284c202905180b98fa5e55f0f8 (diff) |
Use rakumod extension
Diffstat (limited to 'lib/Config/Parser/NULL.rakumod')
-rw-r--r-- | lib/Config/Parser/NULL.rakumod | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/Config/Parser/NULL.rakumod b/lib/Config/Parser/NULL.rakumod new file mode 100644 index 0000000..2845e3c --- /dev/null +++ b/lib/Config/Parser/NULL.rakumod @@ -0,0 +1,30 @@ +#! /usr/bin/env false + +use v6.d; + +use Config::Parser; + +#| The Config::Parser::NULL is a parser to mock with for testing purposes. +#| It exposes an additional method, set-config, so you can set a config +#| Hash to return when calling `read`. +unit class Config::Parser::NULL is Config::Parser; + +my %mock-config; + +#| Return the mock config, skipping the file entirely. +multi method read(IO() $path --> Hash) +{ + %mock-config; +} + +#| Set the mock config to return on read. +method set-config(Hash $config) +{ + %mock-config = $config; +} + +#| Return True, as if writing succeeded. +multi method write(IO() $path, Hash $config --> Bool) +{ + True; +} |