X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-CGI-Ex;a=blobdiff_plain;f=t%2F3_conf_00_base.t;fp=t%2F3_conf_00_base.t;h=e41d8977c40573ced63b545defebf20bd1a4760d;hp=bd6e31c8b7cb91b25b0eb317b4297ed80ad1c059;hb=febed4ec71f803b083c3e61b82b9464e9bfb0992;hpb=ed00221d27dfab1e82ec2ea040ab4c399a91c545 diff --git a/t/3_conf_00_base.t b/t/3_conf_00_base.t index bd6e31c..e41d897 100644 --- a/t/3_conf_00_base.t +++ b/t/3_conf_00_base.t @@ -7,7 +7,11 @@ =cut use strict; -use Test::More tests => 2; +use Test::More tests => 8; +use POSIX qw(tmpnam); + +my $file = tmpnam; +END { unlink $file }; use_ok('CGI::Ex::Conf'); @@ -15,3 +19,33 @@ my $obj = CGI::Ex::Conf->new; ok($obj); ### TODO - re-enable more fileside tests + +if (eval { require JSON }) { + ok(eval { CGI::Ex::Conf::conf_write($file, {foo => "bar"}, {file_type => 'json'}) }, "Could JSON write") || diag($@); + my $ref = eval { CGI::Ex::Conf::conf_read($file, {file_type => 'json'}) }; + is(eval { $ref->{'foo'} }, 'bar', "Could JSON read"); +} else { + SKIP: { + skip("Can't test read/write of json", 2); + }; +} + +if (eval { require YAML }) { + ok(eval { CGI::Ex::Conf::conf_write($file, {foo => "bar2"}, {file_type => 'yaml'}) }, "Could YAML write") || diag($@); + my $ref = eval { CGI::Ex::Conf::conf_read($file, {file_type => 'yaml'}) }; + is(eval { $ref->{'foo'} }, 'bar2', "Could YAML read"); +} else { + SKIP: { + skip("Can't test read/write of yaml", 2); + }; +} + +if (eval { require Data::Dumper }) { + ok(eval { CGI::Ex::Conf::conf_write($file, {foo => "bar2"}, {file_type => 'pl'}) }, "Could Perl write") || diag($@); + my $ref = eval { CGI::Ex::Conf::conf_read($file, {file_type => 'pl'}) }; + is(eval { $ref->{'foo'} }, 'bar2', "Could perl read"); +} else { + SKIP: { + skip("Can't test read/write of pl", 2); + }; +}