File: add_config_file.t

package info (click to toggle)
libconfigreader-simple-perl 1.29-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 220 kB
  • ctags: 27
  • sloc: perl: 657; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 1,010 bytes parent folder | download | duplicates (7)
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
#!/usr/bin/perl
use strict;
use warnings;

use Test::More 'no_plan';

use File::Spec::Functions qw(catfile);

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
my $class  = 'ConfigReader::Simple';
my $method = 'add_config_file';

use_ok( $class );
can_ok( $class, $method );

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Test with a file that does not exist
{
my $filename = 'a/b/c';
ok( ! -e $filename, "Missing file is actually missing" );

my $mock = bless {}, $class;

is( $mock->$method( $filename ), undef, "$method with missing file fails" );
}

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Test with a file that isn't parseable
{
no warnings 'redefine';
no strict 'refs';
local *{ "${class}::parse" } = sub { 0 };

my $filename = catfile( qw(t example.config) );
ok( -e $filename, "$filename exists" );

my $mock = bless {}, $class;

is( $mock->$method( $filename ), undef, "$method with empty file fails" );
}