File Coverage: t/08-config-tiny.t

# File Coverage

File: | t/08-config-tiny.t
Coverage: | 100.0%

line | stmt | bran | cond | sub | pod | time | code
--- | --- | --- | --- | --- | --- | --- | ---
1 |  |  |  |  |  |  | #!/usr/bin/env perl
2 |
3 | 1 1 1 |  |  | 1 |  | 2938 2 25 | use strict;
4 | 1 1 1 |  |  | 1 |  | 3 1 32 | use warnings;
5 | 1 1 1 |  |  | 1 |  | 359 67794 5 | use Test::More;
6 | 1 1 1 |  |  | 1 |  | 413 858 80 | use FindBin qw/$Bin/;
7 | 1 1 1 |  |  | 1 |  | 279 2 53 | use Util::H2O::More qw/o2h2o ini2o o2ini/;
8 | 1 1 1 |  |  | 1 |  | 242 965 22 | use Config::Tiny qw//;
9 | 1 1 1 |  |  | 1 |  | 608 12124 69837 | use File::Temp qw/tempfile/;
10 |
11 |  |  |  |  |  |  | # test wrappers, ini2o and o2ini for backward compat
12 |  |  |  |  |  |  | {
13 | 1 1 |  |  |  |  | 123 5 | my $c = o2h2o( Config::Tiny->read(qq{$Bin/test.ini}) );
14 |
15 | 1 |  |  |  |  | 328 | is $c->section1->var1, q{foo}, q{o2h2p handles Config::Tiny object as expected};
16 |
17 | 1 |  |  |  |  | 353 | my $c2 = ini2o qq{$Bin/test.ini};
18 |
19 | 1 |  |  |  |  | 269 | like $c2, qr/^Util::H2O/, q{ini2o returns Util::H2O object};
20 |
21 | 1 |  |  |  |  | 242 | is $c2->section1->var1, q{foo}, q{ini2o read .ini file and returns object with accessors, as expected};
22 |
23 | 1 |  |  |  |  | 247 | $c2->section1->var1(q{oof});
24 |
25 | 1 |  |  |  |  | 10 | is $c2->section1->var1, q{oof}, q{object with setter works, as expected};
26 |
27 | 1 |  |  |  |  | 259 | my ( $fh, $filename ) = tempfile( SUFFIX => '.ini' );
28 |
29 | 1 |  |  |  |  | 396 | o2ini $c2, qq{$filename};
30 |
31 | 1 |  |  |  |  | 244 | ok -e $filename, qq{$filename exists, so was written by o2ini};
32 |
33 | 1 |  |  |  |  | 241 | my $c3 = ini2o qq{$filename};
34 |
35 | 1 |  |  |  |  | 295 | is $c3->section1->var1, $c2->section1->var1, q{File written by o2ini stored expected configuration state};
36 |  |  |  |  |  |  | }
37 |
38 | 1 |  |  |  |  | 549 | done_testing;