<commit_before>#!/usr/bin/perl -sw
#
# $Id$

require 5.008;
use warnings;
use strict;

use Test::More tests => 5;

use DNSCheck::Config;
use Sys::Hostname;

######################################################################

my $conf;

eval { $conf = new DNSCheck::Config(configfile => './t/config.yaml'); };

ok(!$@, $@);

SKIP: {
    skip "Failed to get an object to test", 4 unless defined($conf);
    ok(ref($conf)                  eq "DNSCheck::Config");
    ok(ref($conf->get("net"))      eq "HASH");
    ok($conf->get("net")->{"smtp"} eq 1);
    ok($conf->get("hostname")      eq hostname);
}<commit_msg>More coverage of Config tests.<commit_after>#!/usr/bin/perl -sw
#
# $Id$

require 5.008;
use warnings;
use strict;

use Test::More;

use DNSCheck::Config;
use Sys::Hostname;

######################################################################

my $conf = new_ok( 'DNSCheck::Config' => [
    configfile => './t/config.yaml',
    policyfile => './policy.yaml',
    localefile => './locale/en.yaml',
    siteconfigfile => './t/config.yaml',
    sitepolicyfile => './policy.yaml',
] );

SKIP: {
    skip "Failed to get an object to test", 4 unless defined( $conf );
    ok( ref( $conf )                  eq "DNSCheck::Config" );
    ok( ref( $conf->get( "net" ) )    eq "HASH" );
    ok( $conf->get( "net" )->{"smtp"} eq 1 );
    ok( $conf->get( "hostname" )      eq hostname );
    is( scalar(keys(%{$conf->{locale}{messages}})), 268, 'Messages are there');
    is( scalar(keys(%{$conf->{loglevels}})), 200, 'Policy data is there');
}

new_ok( 'DNSCheck::Config' => [ configdir => './t', sitedir => './t' ] );
new_ok('DNSCheck::Config');

new_ok('DNSCheck::Config' => [locale => 'gurksallad', policyfile  => 'citronfromage']);
new_ok('DNSCheck::Config' => [ extras => {debug => 1} ] );
new_ok('DNSCheck::Config' => [ interactive => 1 ] );

eval { DNSCheck::Config->new( configfile => '/arglebargle/glop/glyf' ) };
like( $@, qr|Configuration file /arglebargle/glop/glyf not readable| );

done_testing;
{'fraction_non_alphanumeric': 0.27245657568238213, 'fraction_numerical': 0.010421836228287842, 'mean_word_length': 3.8813559322033897, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7011745', 'n_tokens_mistral': 733, 'n_tokens_neox': 703, 'n_words': 160}