[Bps-public-commit] SD - A distributed issue tracker branch, master, updated. 46314563ac365e29175ef2f418340a10f48eb053

spang at bestpractical.com spang at bestpractical.com
Fri Jan 23 11:23:04 EST 2009


The branch, master has been updated
       via  46314563ac365e29175ef2f418340a10f48eb053 (commit)
       via  957e9cf45ce60fd2c6e0526f89277383eb554f55 (commit)
       via  10271fb80eb6ac05dbdd96ba8d710dfce960ba91 (commit)
      from  e6c2f06a38df910976f59b1a4e380dc6291ca9f8 (commit)

Summary of changes:
 t/03-update-ticket-with-editor.t                   |    4 +-
 .../{sd-settings.tmpl => sd-settings-first.tmpl}   |    0 
 .../{sd-settings.tmpl => sd-settings-second.tmpl}  |    2 +-
 .../{sd-settings.tmpl => sd-settings-third.tmpl}   |    4 +-
 t/scripts/settings-editor.pl                       |   57 +++++++++++++++++++
 t/sd-dispatcher.t                                  |    2 +-
 t/sd-settings.t                                    |   58 ++++++++++++++++----
 t/sd-validation.t                                  |   17 +++---
 8 files changed, 119 insertions(+), 25 deletions(-)
 copy t/data/{sd-settings.tmpl => sd-settings-first.tmpl} (100%)
 copy t/data/{sd-settings.tmpl => sd-settings-second.tmpl} (97%)
 rename t/data/{sd-settings.tmpl => sd-settings-third.tmpl} (95%)
 create mode 100755 t/scripts/settings-editor.pl

- Log -----------------------------------------------------------------
commit 10271fb80eb6ac05dbdd96ba8d710dfce960ba91
Author: Christine Spang <spang at bestpractical.com>
Date:   Thu Jan 22 18:19:30 2009 +0200

    finish sd settings tests

diff --git a/t/data/sd-settings.tmpl b/t/data/sd-settings-first.tmpl
similarity index 100%
copy from t/data/sd-settings.tmpl
copy to t/data/sd-settings-first.tmpl
diff --git a/t/data/sd-settings.tmpl b/t/data/sd-settings-second.tmpl
similarity index 97%
copy from t/data/sd-settings.tmpl
copy to t/data/sd-settings-second.tmpl
index 8f1528b..7e57d84 100644
--- a/t/data/sd-settings.tmpl
+++ b/t/data/sd-settings-second.tmpl
@@ -11,7 +11,7 @@ components: ["core","ui","docs","tests"]
 common_ticket_props: ["id","summary","original_replica"]
 
 # uuid: 2F9E6509-4468-438A-A733-246B3061003E
-default_status: ["new"]
+default_status: ["open"]
 
 # uuid: C879A68F-8CFE-44B5-9EDD-14E53933669E
 active_statuses: ["new","open"]
diff --git a/t/data/sd-settings.tmpl b/t/data/sd-settings-third.tmpl
similarity index 95%
rename from t/data/sd-settings.tmpl
rename to t/data/sd-settings-third.tmpl
index 8f1528b..c5b3880 100644
--- a/t/data/sd-settings.tmpl
+++ b/t/data/sd-settings-third.tmpl
@@ -2,7 +2,7 @@
 milestones: ["alpha","beta","1.0"]
 
 # uuid: 0AEC922F-57B1-44BE-9588-816E5841BB18
-default_component: ["core"]
+default_component: ["ui"]
 
 # uuid: 6CBD84A1-4568-48E7-B90C-F1A5B7BD8ECD
 components: ["core","ui","docs","tests"]
@@ -11,7 +11,7 @@ components: ["core","ui","docs","tests"]
 common_ticket_props: ["id","summary","original_replica"]
 
 # uuid: 2F9E6509-4468-438A-A733-246B3061003E
-default_status: ["new"]
+default_status: ["open"]
 
 # uuid: C879A68F-8CFE-44B5-9EDD-14E53933669E
 active_statuses: ["new","open"]
diff --git a/t/scripts/settings-editor.pl b/t/scripts/settings-editor.pl
new file mode 100755
index 0000000..8d796b6
--- /dev/null
+++ b/t/scripts/settings-editor.pl
@@ -0,0 +1,57 @@
+#!/usr/bin/perl -i
+use strict;
+use warnings;
+
+use Prophet::Util;
+
+# perl script to trick Proc::InvokeEditor with for the settings command
+
+my %tmpl_files = ( '--first' => 'sd-settings-first.tmpl',
+                   '--second' => 'sd-settings-second.tmpl',
+                 );
+
+my $option = shift @ARGV;
+my $tmpl_file = $tmpl_files{$option};
+
+# the test script passes in a temp file for us to write whether the
+# template is ok or not to
+my $status_tmp_file = shift;
+
+my @valid_template =
+    Prophet::Util->slurp("t/data/$tmpl_file");
+
+my @template = ();
+
+while (<>) {
+    push @template, $_;
+
+    if ($option eq '--first') {
+        s/(?<=^default_status: \[")new(?="\])/open/; # valid json change
+        s/^default_milestone(?=: \["alpha"\])$/invalid_setting/; # changes setting name
+        s/(?<=uuid: B)A(?=B613BD)/F/; # changes a UUID to an invalid one
+        s/^project_name//; # deletes setting
+    } elsif ($option eq '--second') {
+        s/(?<=^default_component: \[")core(?="\])/ui/; # valid json change
+        s/(?<=^default_milestone: \["alpha")]$//; # invalid json
+    }
+    print;
+}
+
+my $ok = 1;
+
+my %seen;     # lookup table
+my @vonly;    # answer
+
+# build lookup table
+ at seen{@template} = ( );
+
+for my $line (@valid_template) {
+    push(@vonly, $line) unless exists $seen{$line};
+}
+
+# if anything is only in the valid template, we don't match
+$ok = 0 if scalar @vonly;
+
+open STATUSFILE, '>', $status_tmp_file;
+$ok ? print STATUSFILE "ok!" : print STATUSFILE "not ok!";
+close STATUSFILE;
diff --git a/t/sd-settings.t b/t/sd-settings.t
index 27d4812..30fb75a 100644
--- a/t/sd-settings.t
+++ b/t/sd-settings.t
@@ -2,9 +2,10 @@
 
 use strict;
 
-use Prophet::Test tests => 2;
+use Prophet::Test tests => 8;
 use App::SD::Test;
 use Prophet::Util;
+use File::Temp qw(tempfile);
 no warnings 'once';
 
 # test the CLI and interactive UIs for showing and updating settings
@@ -26,12 +27,12 @@ run_output_matches( 'sd', [ 'settings', '--set', '--', 'common_ticket_props',
     '["id","summary","original_replica"]' ],
     [
         'Trying to change common_ticket_props from ["id","summary","status","milestone","component","owner","created","due","creator","reporter","original_replica"] to ["id","summary","original_replica"].',
-        'Changed common_ticket_props from ["id","summary","status","milestone","component","owner","created","due","creator","reporter","original_replica"] to ["id","summary","original_replica"].',
+        ' -> Changed.',
     ], [], "settings --set went ok",
 );
 
 # check with settings --show
-my @valid_settings_output = Prophet::Util->slurp('t/data/sd-settings.tmpl');
+my @valid_settings_output = Prophet::Util->slurp('t/data/sd-settings-first.tmpl');
 chomp (@valid_settings_output);
 
 run_output_matches(
@@ -42,17 +43,54 @@ run_output_matches(
 
 # test sd settings (interactive editing)
 
+(undef, my $filename) = tempfile();
+diag ("interactive template status will be found in $filename");
 # first set the editor to an editor script
-# App::SD::Test->set_editor("ticket-update-editor.pl --verbose $replica_uuid $ticket_uuid");
+App::SD::Test->set_editor("settings-editor.pl --first $filename");
 
 # then edit the settings
-# run_output_matches( 'sd', [ 'settings' ],
-#     [
-#         'Trying to change common_ticket_props from ["id","summary","status","milestone","component","owner","created","due","creator","reporter","original_replica"] to ["id","summary","original_replica"].',
-#         'Changed common_ticket_props from ["id","summary","status","milestone","component","owner","created","due","creator","reporter","original_replica"] to ["id","summary","original_replica"].',
-#     ], [], "interactive settings set went ok",
-# );
+run_output_matches_unordered( 'sd', [ 'settings' ],
+    [
+        'Changed default_status from ["new"] to ["open"].',
+        'Setting with uuid "BFB613BD-9E25-4612-8DE3-21E4572859EA" does not exist.',
+    ], [], "interactive settings set went ok",
+);
+
+# check the tempfile to see if the template presented to the editor was correct
+chomp(my $template_ok = Prophet::Util->slurp($filename));
+is($template_ok, 'ok!', "interactive template was correct");
 
 # check the settings with settings --show
+ at valid_settings_output = Prophet::Util->slurp('t/data/sd-settings-second.tmpl');
+chomp (@valid_settings_output);
+
+run_output_matches(
+    'sd',
+    [ qw/settings --show/ ],
+    [ @valid_settings_output ], [], "changed settings output matches"
+);
 
 # test setting to invalid json
+(undef, my $second_filename) = tempfile();
+diag ("interactive template status will be found in $second_filename");
+App::SD::Test->set_editor("settings-editor.pl --second $second_filename");
+run_output_matches_unordered( 'sd', [ 'settings' ],
+    [
+        'Changed default_component from ["core"] to ["ui"].',
+        qr/^An error occured setting default_milestone to \["alpha":/,
+    ], [], "interactive settings set with JSON error went ok",
+);
+
+# check the tempfile to see if the template presented to the editor was correct
+chomp($template_ok = Prophet::Util->slurp($filename));
+is($template_ok, 'ok!', "interactive template was correct");
+
+# check the settings with settings --show
+ at valid_settings_output = Prophet::Util->slurp('t/data/sd-settings-third.tmpl');
+chomp (@valid_settings_output);
+
+run_output_matches(
+    'sd',
+    [ qw/settings --show/ ],
+    [ @valid_settings_output ], [], "changed settings output matches"
+);

commit 957e9cf45ce60fd2c6e0526f89277383eb554f55
Author: Christine Spang <spang at bestpractical.com>
Date:   Fri Jan 23 18:02:27 2009 +0200

    misc minor test updates

diff --git a/t/03-update-ticket-with-editor.t b/t/03-update-ticket-with-editor.t
index 930e1d5..ba2276b 100644
--- a/t/03-update-ticket-with-editor.t
+++ b/t/03-update-ticket-with-editor.t
@@ -18,7 +18,7 @@ run_output_matches( 'sd', [ 'settings', '--set', '--', 'common_ticket_props',
     '["id","summary","status","milestone","owner","created","due","creator","reporter","original_replica"]' ],
     [
         'Trying to change common_ticket_props from ["id","summary","status","milestone","component","owner","created","due","creator","reporter","original_replica"] to ["id","summary","status","milestone","owner","created","due","creator","reporter","original_replica"].',
-        'Changed common_ticket_props from ["id","summary","status","milestone","component","owner","created","due","creator","reporter","original_replica"] to ["id","summary","status","milestone","owner","created","due","creator","reporter","original_replica"].',
+        ' -> Changed.',
     ]
 );
 
@@ -136,7 +136,7 @@ run_output_matches( 'sd', [ 'settings', '--set', '--', 'common_ticket_props',
     '["id","summary","status","milestone","owner","created","due","creator","original_replica"]' ],
     [
         'Trying to change common_ticket_props from ["id","summary","status","milestone","owner","created","due","creator","reporter","original_replica"] to ["id","summary","status","milestone","owner","created","due","creator","original_replica"].',
-        'Changed common_ticket_props from ["id","summary","status","milestone","owner","created","due","creator","reporter","original_replica"] to ["id","summary","status","milestone","owner","created","due","creator","original_replica"].',
+        ' -> Changed.',
     ]
 );
 
diff --git a/t/sd-dispatcher.t b/t/sd-dispatcher.t
index 8135ceb..e9979cd 100644
--- a/t/sd-dispatcher.t
+++ b/t/sd-dispatcher.t
@@ -154,7 +154,7 @@ TODO: {
         [
             "id: $yatta_id ($yatta_uuid)",
             'summary: YATTA',
-            'status: new',
+            'status: closed',
             'milestone: alpha',
             'component: core',
             'owner: jesse at bestpractical.com',
diff --git a/t/sd-validation.t b/t/sd-validation.t
index b9df696..9920c68 100644
--- a/t/sd-validation.t
+++ b/t/sd-validation.t
@@ -23,11 +23,10 @@ run_output_matches( 'sd', [ 'ticket',
     [  qr/(\d+) YATTA new/]
 );
 
-
 is_script_output( 'sd', [ 'ticket',  
     'update', '--uuid', $yatta_uuid, '--', '--status', 'super'
     ],
-   [undef],  # stdout
+   [],  # stdout
     [qr/Validation error for 'status': 'super' is not a valid status/], # stderr
     "Despite the magic power phrase of 'yatta', super is not a valid bug status"
 );
@@ -39,17 +38,17 @@ run_output_matches( 'sd', [ 'ticket',
 
 # regression test: when multiple errors are present they should be
 # separated by newlines
-is_script_output( 'sd', [ 'ticket',  
+run_output_matches( 'sd', [ 'ticket',  
     'update', '--uuid', $yatta_uuid, '--', '--status', 'super',
     '--component', 'awesome'
     ],
-   [undef],  # stdout
+   [],  # stdout
     [qr/Validation error for 'component': 'awesome' is not a valid component/,
     qr/Validation error for 'status': 'super' is not a valid status/], # stderr
     "Despite the magic power phrase of 'yatta', super is not a valid bug status"
 );
 
-is_script_output( 'sd', [ 'ticket',  
+run_output_matches( 'sd', [ 'ticket',  
     'update', '--uuid', $yatta_uuid, '--', '--status', 'stalled'
     ],
    [qr/Ticket \d+ \($yatta_uuid\) updated./], # stdout
@@ -65,9 +64,9 @@ run_output_matches( 'sd', [ 'ticket',
 
 
 my $sylar_uuid;
-is_script_output( 'sd', [ 'ticket',
+run_output_matches( 'sd', [ 'ticket',
     'create', '--', '--summary', 'Sylar!', '--status', 'evil' ],
-    [undef],
+    [],
     [qr/Validation error for 'status': 'evil' is not a valid status/],
     "Sylar can't create an eeevil ticket"
 );
@@ -78,7 +77,7 @@ run_output_matches( 'sd', [ 'ticket',
 );
 
 
-is_script_output( 'sd', [ 'ticket',  
+run_output_matches( 'sd', [ 'ticket',  
     'update', '--uuid', $yatta_uuid, '--', '--status', ''
     ],
    [], # stdout
@@ -95,7 +94,7 @@ run_output_matches( 'sd', [ 'ticket',
 
 
 # check to make sure that we can force-set props
-is_script_output( 'sd', [ 'ticket',  
+run_output_matches( 'sd', [ 'ticket',  
     'update', '--uuid', $yatta_uuid, '--', '--status', 'super!'
     ],
     [qr/Ticket $yatta_id \($yatta_uuid\) updated/], #stdout

commit 46314563ac365e29175ef2f418340a10f48eb053
Merge: 957e9cf... e6c2f06...
Author: Christine Spang <spang at bestpractical.com>
Date:   Fri Jan 23 18:22:56 2009 +0200

    Merge branch 'master' of code.bestpractical.com:/git/sd


-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list