blob: 2352cfccb267244579300a9c50daae26cfbe4309 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#! /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.
multi method read(Str $path --> Hash)
{
%mock-config;
}
multi method read(IO::Path $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(Str $path, Hash $config --> Bool)
{
True;
}
multi method write(IO::Path $path, Hash $config --> Bool)
{
True;
}
}
|