[Bps-public-commit] r16548 - in sd/trunk: .

spang at bestpractical.com spang at bestpractical.com
Sun Oct 26 17:09:28 EDT 2008


Author: spang
Date: Sun Oct 26 17:09:27 2008
New Revision: 16548

Added:
   sd/trunk/t/05-config-file-loading.t
   sd/trunk/t/prophet_testing.conf
Modified:
   sd/trunk/   (props changed)

Log:
 r50907 at loki:  spang | 2008-10-26 13:08:41 -0400
 Test coverage for config file loading


Added: sd/trunk/t/05-config-file-loading.t
==============================================================================
--- (empty file)
+++ sd/trunk/t/05-config-file-loading.t	Sun Oct 26 17:09:27 2008
@@ -0,0 +1,110 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use Prophet::Test tests => 10;
+use App::SD::Test;
+use File::Temp qw/tempdir/;
+use Path::Class;
+
+
+no warnings 'once';
+
+BEGIN {
+    require File::Temp;
+    $ENV{'PROPHET_REPO'} = $ENV{'SD_REPO'} = $ENV{'HOME'} = File::Temp::tempdir( CLEANUP => 0 ) . '/_svb';
+    diag "export SD_REPO=".$ENV{'PROPHET_REPO'} ."\n";
+    diag "export HOME=".$ENV{'PROPHET_REPO'} ."\n";
+    $ENV{'PROPHET_APP_CONFIG'} = undef; # clear this because Prophet::Test sets it
+}
+
+# Tests the config file order of preference laid out in App::SD::Config
+
+# create from sd
+my ($yatta_id, $yatta_uuid) = create_ticket_ok( '--summary', 'YATTA');
+
+# default config file
+diag("Testing default config file\n");
+
+run_output_matches( 'sd', [ 'ticket',
+    'list', '--regex', '.' ],
+    [ qr/(\d+) YATTA new/]
+);
+
+$ENV{'SD_CONFIG'} = $ENV{'PROPHET_APP_CONFIG'} = undef;  # override App::SD::Test
+ok( ! $ENV{'SD_CONFIG'}, "SD_CONFIG env var has been cleared" );
+ok( ! $ENV{'PROPHET_APP_CONFIG'}, "PROPHET_APP_CONFIG env var has been cleared" );
+
+# Test from least-preferred to most preferred, leaving the least-preferred
+# files in place to make sure the next-most-preferred file is preferred
+# over all the files beneath it.
+
+diag("Testing \$HOME/.prophetrc\n");
+
+my $config_filename = $ENV{'HOME'} . '/.prophetrc';
+
+App::SD::Test->write_to_file($config_filename,
+    "summary_format_ticket = %4s },\$luid | %-11.11s,status | %-60.60s,summary\n");
+
+run_output_matches( 'sd', [ 'ticket',
+    'list', '--regex', '.' ],
+    [ qr/\s+(\d+) } new         YATTA/]
+);
+
+diag("Testing PROPHET_APP_CONFIG\n");
+
+$config_filename = $ENV{'HOME'} . '/config-test';
+$ENV{'PROPHET_APP_CONFIG'} = $config_filename;
+
+App::SD::Test->write_to_file($config_filename,
+    "summary_format_ticket = %-9.9s,status | %-60.60s,summary\n");
+
+run_output_matches( 'sd', [ 'ticket',
+    'list', '--regex', '.' ],
+    [ qr/new       YATTA/]
+);
+
+diag("Testing \$HOME/.sdrc\n");
+
+$config_filename = $ENV{'HOME'} . '/.sdrc';
+
+App::SD::Test->write_to_file($config_filename,
+    "summary_format_ticket = %4s },\$luid | %-7.7s,status | %-60.60s,summary\n");
+
+run_output_matches( 'sd', [ 'ticket',
+    'list', '--regex', '.' ],
+    [ qr/\s+(\d+) } new     YATTA/]
+);
+
+diag("Testing fs_root/prophetrc\n");
+
+$config_filename = $ENV{'SD_REPO'} . '/prophetrc';
+
+App::SD::Test->write_to_file($config_filename,
+    "summary_format_ticket = %4s },\$luid | %-10.10s,status | %-60.60s,summary\n");
+
+run_output_matches( 'sd', [ 'ticket',
+    'list', '--regex', '.' ],
+    [ qr/\s+(\d+) } new        YATTA/]
+);
+
+diag("Testing fs_root/sdrc\n");
+
+$config_filename = $ENV{'SD_REPO'} . '/sdrc';
+
+App::SD::Test->write_to_file($config_filename,
+    "summary_format_ticket = %4s },\$luid | %-6.6s,status | %-60.60s,summary\n");
+
+run_output_matches( 'sd', [ 'ticket',
+    'list', '--regex', '.' ],
+    [ qr/\s+(\d+) } new    YATTA/]
+);
+
+diag("Testing SD_CONFIG\n");
+
+$ENV{'SD_CONFIG'} = 't/prophet_testing.conf';
+
+run_output_matches( 'sd', [ 'ticket',
+    'list', '--regex', '.' ],
+    [ qr/(\d+) YATTA new/]
+);

Added: sd/trunk/t/prophet_testing.conf
==============================================================================
--- (empty file)
+++ sd/trunk/t/prophet_testing.conf	Sun Oct 26 17:09:27 2008
@@ -0,0 +1 @@
+reporter_email = someone at example.com



More information about the Bps-public-commit mailing list