From 88425ea8064b579d47d6b8c63906612f1aceeef8 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Sat, 29 Jul 2017 02:43:15 +0200 Subject: Add tests for reading a List of files --- lib/Config/Parser/NULL.pm6 | 6 +++--- t/01-reading.t | 13 ++++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/Config/Parser/NULL.pm6 b/lib/Config/Parser/NULL.pm6 index ff384b1..5113043 100644 --- a/lib/Config/Parser/NULL.pm6 +++ b/lib/Config/Parser/NULL.pm6 @@ -9,18 +9,18 @@ use Config::Parser; #| Hash to return when calling `read`. class Config::Parser::NULL is Config::Parser { - my $mock-config; + my %mock-config = (); #| Return the mock config, skipping the file entirely. method read(Str $path --> Hash) { - $mock-config; + %mock-config; } #| Set the mock config to return on read. method set-config(Hash $config) { - $mock-config = $config; + %mock-config = $config; } #| Return True, as if writing succeeded. diff --git a/t/01-reading.t b/t/01-reading.t index f834226..07e92c3 100644 --- a/t/01-reading.t +++ b/t/01-reading.t @@ -4,7 +4,7 @@ use v6.c; use Test; use lib "lib"; -plan 4; +plan 5; use Config; @@ -37,3 +37,14 @@ is-deeply $config.get(), { "d" => "another" } }, "Correctly merges new hash into existing config"; + +subtest { + plan 3; + + # Use the NULL parser to mock the parser + my $parser = "Config::Parser::NULL"; + + is $config.read(("t/files/config", "t/files/config.yaml"), $parser, skip-not-found => True), True, "All paths exist"; + is $config.read(("t/files/config", "t/files/none", "t/files/config.yaml"), $parser, skip-not-found => True), True, "At least one path exists"; + is $config.read(("t/files/none", "t/files/none.yaml"), $parser, skip-not-found => True), False, "No paths exist"; +}, "Read with a List of paths"; -- cgit v1.1