]> Dogcows Code - chaz/p5-CGI-Ex/blob - t/3_conf_00_base.t
CGI::Ex 2.27
[chaz/p5-CGI-Ex] / t / 3_conf_00_base.t
1 # -*- Mode: Perl; -*-
2
3 =head1 NAME
4
5 3_conf_00_base.t - Test for the basic functionality of CGI::Ex::Conf
6
7 =cut
8
9 use strict;
10 use Test::More tests => 8;
11 use POSIX qw(tmpnam);
12
13 my $file = tmpnam;
14 END { unlink $file };
15
16 use_ok('CGI::Ex::Conf');
17
18 my $obj = CGI::Ex::Conf->new;
19 ok($obj);
20
21 ### TODO - re-enable more fileside tests
22
23 if (eval { require JSON }) {
24 ok(eval { CGI::Ex::Conf::conf_write($file, {foo => "bar"}, {file_type => 'json'}) }, "Could JSON write") || diag($@);
25 my $ref = eval { CGI::Ex::Conf::conf_read($file, {file_type => 'json'}) };
26 is(eval { $ref->{'foo'} }, 'bar', "Could JSON read");
27 } else {
28 SKIP: {
29 skip("Can't test read/write of json", 2);
30 };
31 }
32
33 if (eval { require YAML }) {
34 ok(eval { CGI::Ex::Conf::conf_write($file, {foo => "bar2"}, {file_type => 'yaml'}) }, "Could YAML write") || diag($@);
35 my $ref = eval { CGI::Ex::Conf::conf_read($file, {file_type => 'yaml'}) };
36 is(eval { $ref->{'foo'} }, 'bar2', "Could YAML read");
37 } else {
38 SKIP: {
39 skip("Can't test read/write of yaml", 2);
40 };
41 }
42
43 if (eval { require Data::Dumper }) {
44 ok(eval { CGI::Ex::Conf::conf_write($file, {foo => "bar2"}, {file_type => 'pl'}) }, "Could Perl write") || diag($@);
45 my $ref = eval { CGI::Ex::Conf::conf_read($file, {file_type => 'pl'}) };
46 is(eval { $ref->{'foo'} }, 'bar2', "Could perl read");
47 } else {
48 SKIP: {
49 skip("Can't test read/write of pl", 2);
50 };
51 }
This page took 0.029497 seconds and 4 git commands to generate.