always run all tests during release
[p5sagit/Config-Any.git] / t / 52-json.t
index f4e45c3..8bc5cc9 100644 (file)
@@ -1,11 +1,37 @@
-use Test::More tests => 2;\r
-\r
-use Config::Any::JSON;\r
-\r
-my $config = eval { Config::Any::JSON->load( 't/conf/conf.json' ) };\r
-\r
-SKIP: {\r
-    skip "Couldn't Load JSON plugin", 2 if $@;\r
-    ok( $config );\r
-    is( $config->{ name }, 'TestApp' );\r
-}\r
+use strict;
+use warnings;
+
+use Test::More;
+use Config::Any;
+use Config::Any::JSON;
+
+if ( !Config::Any::JSON->is_supported && !$ENV{RELEASE_TESTING} ) {
+    plan skip_all => 'JSON format not supported';
+}
+else {
+    plan tests => 6;
+}
+
+{
+    my $config = Config::Any::JSON->load( 't/conf/conf.json' );
+    ok( $config );
+    is( $config->{ name }, 'TestApp' );
+}
+
+# test invalid config
+{
+    my $file = 't/invalid/conf.json';
+    my $config = eval { Config::Any::JSON->load( $file ) };
+
+    is $config, undef, 'config load failed';
+    isnt $@, '', 'error thrown';
+}
+
+# parse error generated on invalid config
+{
+    my $file = 't/invalid/conf.json';
+    my $config = eval { Config::Any->load_files( { files => [$file], use_ext => 1} ) };
+
+    is $config, undef, 'config load failed';
+    isnt $@, '', 'error thrown';
+}