[Bps-public-commit] r16468 - in Prophet/trunk/t/Settings: bin lib lib/App lib/App/Settings t

jesse at bestpractical.com jesse at bestpractical.com
Tue Oct 21 21:20:12 EDT 2008


Author: jesse
Date: Tue Oct 21 21:20:12 2008
New Revision: 16468

Added:
   Prophet/trunk/t/Settings/
   Prophet/trunk/t/Settings/bin/
   Prophet/trunk/t/Settings/bin/settings   (contents, props changed)
   Prophet/trunk/t/Settings/lib/
   Prophet/trunk/t/Settings/lib/App/
   Prophet/trunk/t/Settings/lib/App/Settings/
   Prophet/trunk/t/Settings/lib/App/Settings.pm
   Prophet/trunk/t/Settings/lib/App/Settings/Bug.pm
   Prophet/trunk/t/Settings/lib/App/Settings/CLI.pm
   Prophet/trunk/t/Settings/t/
   Prophet/trunk/t/Settings/t/sync-database-settings.t

Log:
* Added Settings tests. (for sync)

Added: Prophet/trunk/t/Settings/bin/settings
==============================================================================
--- (empty file)
+++ Prophet/trunk/t/Settings/bin/settings	Tue Oct 21 21:20:12 2008
@@ -0,0 +1,22 @@
+#!/usr/bin/env perl 
+use warnings;
+use strict;
+use App::Settings::CLI;
+use lib 'lib';
+use lib '../../lib';
+# Moose likes generating very noisy backtraces. Most users don't need to see
+# anything more than the root cause of the failure. Developers and the curious
+# can set environment variable SD_VERBOSE_ERROR to retain the backtraces.
+# When Moose's error throwing is more malleable we should switch to using that.
+unless ($ENV{'TEST_VERBOSE'}) {
+    $SIG{__DIE__} = sub {
+        my $line = shift;
+        $line =~ s/\n.*//s if ($line =~ /at line/s);
+        $line .= "\n"; $line =~ s/\n+$/\n/gs;
+        die $line;
+    };
+}
+
+my $cli = App::Settings::CLI->new;
+$cli->run_one_command(@ARGV);
+

Added: Prophet/trunk/t/Settings/lib/App/Settings.pm
==============================================================================
--- (empty file)
+++ Prophet/trunk/t/Settings/lib/App/Settings.pm	Tue Oct 21 21:20:12 2008
@@ -0,0 +1,23 @@
+package App::Settings;
+use Moose;
+
+extends 'Prophet::App';
+our $VERSION = '0.01';
+
+
+sub database_settings {
+{ 
+        statuses            => ['24183C4D-EFD0-4B16-A207-ED7598E875E6' => qw/new open stalled closed/],
+        default_status      => ['2F9E6509-4468-438A-A733-246B3061003E' => 'new' ],
+        components          => ['6CBD84A1-4568-48E7-B90C-F1A5B7BD8ECD' => qw/core ui docs tests/],
+        default_component   => ['0AEC922F-57B1-44BE-9588-816E5841BB18' => 'core'],
+        milestones          => ['1AF5CF74-A6D4-417E-A738-CCE64A0A7F71' => qw/alpha beta 1.0/],
+        default_milestone   => ['BAB613BD-9E25-4612-8DE3-21E4572859EA' => 'alpha']
+};
+
+}
+
+__PACKAGE__->meta->make_immutable;
+
+no Moose;
+1;

Added: Prophet/trunk/t/Settings/lib/App/Settings/Bug.pm
==============================================================================
--- (empty file)
+++ Prophet/trunk/t/Settings/lib/App/Settings/Bug.pm	Tue Oct 21 21:20:12 2008
@@ -0,0 +1,31 @@
+use warnings;
+use strict;
+
+package App::Settings::Bug;
+use Moose;
+extends 'Prophet::Record';
+
+use base qw/Prophet::Record/;
+
+
+sub new { shift->SUPER::new( @_, type => 'bug' ) }
+
+sub validate_prop_name {
+    my $self = shift;
+    my %args = (@_);
+
+    return 1 if ( $args{props}->{'name'} eq 'Jesse' );
+
+    return 0;
+
+}
+
+sub canonicalize_prop_email {
+    my $self = shift;
+    my %args = (@_);
+    $args{props}->{email} = lc( $args{props}->{email} );
+}
+
+sub default_prop_status { 'new' }
+
+1;

Added: Prophet/trunk/t/Settings/lib/App/Settings/CLI.pm
==============================================================================
--- (empty file)
+++ Prophet/trunk/t/Settings/lib/App/Settings/CLI.pm	Tue Oct 21 21:20:12 2008
@@ -0,0 +1,17 @@
+#!/usr/bin/env perl
+package App::Settings::CLI;
+use Moose;
+extends 'Prophet::CLI';
+
+use App::Settings;
+
+has '+app_class' => (
+    default => 'App::Settings',
+);
+
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+

Added: Prophet/trunk/t/Settings/t/sync-database-settings.t
==============================================================================
--- (empty file)
+++ Prophet/trunk/t/Settings/t/sync-database-settings.t	Tue Oct 21 21:20:12 2008
@@ -0,0 +1,41 @@
+#!/usr/bin/perl 
+#
+use warnings;
+use strict;
+
+use Prophet::Test tests => 11;
+use lib 't/Settings/lib';
+
+
+as_alice {
+    run_ok( 'settings', [qw(create --type Bug -- --status new --from alice )], "Created a record as alice" );
+    run_output_matches( 'settings', [qw(search --type Bug --regex .)], [qr/new/], " Found our record" );
+    my ($return, $stdout, $stderr) = run_script('settings', [qw(settings --show)]);
+    like($stdout, qr/default_status: \["new"\]/, "the original milestone list is there");
+    run_ok('settings', [qw(settings --set -- default_status ["open"])]);
+    ($return, $stdout, $stderr) = run_script('settings', [qw(settings --show)]);
+    like($stdout, qr/default_status: \["open"\]/, "the original milestone list is there");
+
+
+
+};
+as_bob {
+    run_ok( 'settings', [ 'merge', '--from', repo_uri_for('alice'), '--to', repo_uri_for('bob') ], "Sync ran ok!" );
+    my ($return, $stdout, $stderr) = run_script('settings', [qw(settings --show)]);
+    like($stdout, qr/default_status: \["open"\]/, "the original milestone list is there");
+    run_ok('settings', [qw(settings --set -- default_status ["stalled"])]);
+    ($return, $stdout, $stderr) = run_script('settings', [qw(settings --show)]);
+    like($stdout, qr/default_status: \["stalled"\]/, "the original milestone list is there");
+
+};
+
+
+as_alice {
+    run_ok( 'settings', [ 'merge', '--from', repo_uri_for('bob'), '--to', repo_uri_for('alice') ], "Sync ran ok!" );
+    my ($return, $stdout, $stderr) = run_script('settings', [qw(settings --show)]);
+    like($stdout, qr/default_status: \["stalled"\]/, "the original milestone list is there");
+
+};
+exit;
+
+



More information about the Bps-public-commit mailing list