From e547b7507e6878efdccb744b7d6cd5250c6c69b9 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Thu, 16 Feb 2017 14:28:01 +0200 Subject: Improve config parser. Add more tests. * MANIFEST: Update. * lib/App/Beam/Config.pm: Rewrite 'error' as method. Check for missing mandatory statements. * t/TestConfig.pm: New file. * t/conf01.t: New file. * t/conf02.t: New file. * t/conf03.t: New file. * t/config.t: Remove. * t/f.conf: Remove. --- t/conf04.t | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 t/conf04.t (limited to 't/conf04.t') diff --git a/t/conf04.t b/t/conf04.t new file mode 100644 index 0000000..2f1d8d1 --- /dev/null +++ b/t/conf04.t @@ -0,0 +1,39 @@ +# -*- perl -*- +use lib 't'; +use strict; +use Test; +use TestConfig; + +plan(tests => 1); + +my %keywords = ( + core => { + section => { + 'retain-interval' => { mandatory => 1 }, + 'tempdir' => 1, + 'verbose' => 1, + } + }, + backend => { + section => { + file => { + section => { + name => { mandatory => 1 }, + local => 1 + } + } + } + } +); + +my $cfg = new TestConfig(parameters => \%keywords, + expect => [ 'mandatory variable "core.retain-interval" not set', + 'mandatory variable "backend.file.name" not set' ]); +ok($cfg->errors()==2); + +__DATA__ +# This is a sample configuration file +[core] + tempdir = /tmp +[backend file] + local = 1 -- cgit v1.2.1