[Bps-public-commit] r14279 - Prophet/trunk/t

jesse at bestpractical.com jesse at bestpractical.com
Fri Jul 18 15:14:17 EDT 2008


Author: jesse
Date: Fri Jul 18 15:14:14 2008
New Revision: 14279

Added:
   Prophet/trunk/t/config.t
   Prophet/trunk/t/test_app.conf

Log:
* Add the tests for config

Added: Prophet/trunk/t/config.t
==============================================================================
--- (empty file)
+++ Prophet/trunk/t/config.t	Fri Jul 18 15:14:14 2008
@@ -0,0 +1,47 @@
+#!/usr/bin/perl 
+#
+use warnings;
+use strict;
+use Prophet::Test 'no_plan';
+use File::Temp qw'tempdir';
+    $ENV{'PROPHET_REPO'} = tempdir( CLEANUP => 0 ) . '/repo-' . $$;
+
+
+use_ok('Prophet::CLI');
+# Test basic config file parsing
+use_ok('Prophet::Config');
+my $config = Prophet::Config->new(app_handle => Prophet::CLI->new->app_handle);
+isa_ok($config => 'Prophet::Config');
+can_ok($config  => 'load_from_files');
+
+can_ok($config, 'get');
+can_ok($config, 'set');
+can_ok($config, 'list');
+
+is($config->get('_does_not_exist'), undef);
+is($config->set('_does_not_exist' => 'hey you!'), 'hey you!');
+is($config->get('_does_not_exist'), 'hey you!');
+is_deeply([$config->list], ['_does_not_exist'], "The deep structures match");
+
+# load up a prophet app instance
+
+
+my $a = Prophet::CLI->new();
+can_ok($a, 'app_handle');
+can_ok($a->app_handle, 'config');
+my $c = $a->app_handle->config;
+
+# interrogate its config to see if we have any config options set
+my @keys = $c->list;
+is (scalar @keys,0);
+
+# set a config file 
+{ local $ENV{'PROPHET_APP_CONFIG'} = 't/test_app.conf';
+my $conf = Prophet::Config->new(app_handle => Prophet::CLI->new->app_handle);
+# interrogate its config to see if we have any config options set
+my @keys = $conf->list;
+is (scalar @keys,2);
+}
+
+# run the cli "show config" command 
+# make sure it matches with our file

Added: Prophet/trunk/t/test_app.conf
==============================================================================
--- (empty file)
+++ Prophet/trunk/t/test_app.conf	Fri Jul 18 15:14:14 2008
@@ -0,0 +1,5 @@
+#This is not a config directive
+foo=bar
+# nor is this
+
+re = rawr



More information about the Bps-public-commit mailing list