diff options
author | Patrick Spek <p.spek@tyil.nl> | 2017-04-26 23:08:59 +0200 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2017-04-26 23:08:59 +0200 |
commit | ed219a26574e05ba27264d73e75e5690e478570f (patch) | |
tree | fafb21c1c9db6f543fb213c9d658e5f91f027788 /lib/Config/Parser | |
parent | 845c2d891e12b7abe006aa1e36c1201266b29a51 (diff) |
Add Config::Parser::NULL for testcases
Diffstat (limited to 'lib/Config/Parser')
-rw-r--r-- | lib/Config/Parser/NULL.pm6 | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/Config/Parser/NULL.pm6 b/lib/Config/Parser/NULL.pm6 new file mode 100644 index 0000000..ff384b1 --- /dev/null +++ b/lib/Config/Parser/NULL.pm6 @@ -0,0 +1,31 @@ +#! /usr/bin/env false + +use v6.c; + +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`. +class Config::Parser::NULL is Config::Parser +{ + my $mock-config; + + #| Return the mock config, skipping the file entirely. + method read(Str $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. + method write(Str $path, Hash $config --> Bool) + { + True; + } +} |