rev 1316 - in trunk/siesta: bin t

[prev] [thread] [next] [lurker] [Date index for 2003/08/12]

From: simon
Subject: rev 1316 - in trunk/siesta: bin t
Date: 12:47 on 12 Aug 2003
Author: simon
Date: 2003-08-12 12:47:04 +0100 (Tue, 12 Aug 2003)
New Revision: 1316

Modified:
   trunk/siesta/bin/nacho
   trunk/siesta/t/30nacho.t
Log:
Tests and fixes for deferring messages from nacho


Modified: trunk/siesta/bin/nacho
===================================================================
--- trunk/siesta/bin/nacho	2003-08-11 18:12:23 UTC (rev 1315)
+++ trunk/siesta/bin/nacho	2003-08-12 11:47:04 UTC (rev 1316)
@@ -611,53 +611,47 @@
 
 
 
-=head2 show-deferred member_id [ deferred_id ]
+=head2 show-deferred [ deferred_id ]
 
-Show all the deferred messages for a user name or, if
-and id is passed in, show that deferred message.
+Show all the deferred messages or, if an id is 
+passed in, show that deferred message.
 
 =cut
 
 
 $commands{'show-deferred'} = sub {
-    my $user_id = shift || die "You must pass a user name\n";
     my $mess_id = shift;
 
-    my $user = Siesta::Member->load($user_id)
-      or die "No such user $user_id\n";
 
+    # show an individual deferred message
     if (defined $mess_id) {
-        my $deferred = Siesta::Deferred->search( who => $user, id => $mess_id );
-        if (defined $deferred) {
-            print $deferred->message->as_string;
-        }
-        else {
-            print "No such deferred message\n";
-        }
+        my $deferred = Siesta::Deferred->retrieve($mess_id) 
+            or die "No such deferred message\n";
+        print $deferred->message->as_string;
+        return;
     }
-    else {
-        foreach my $deferred (Siesta::Deferred->search( who => $user )) {
-            print $deferred->id(),") ",$deferred->message->subject(),"\n";
-        }
+
+
+    # otherwise 
+    foreach my $deferred ( Siesta::Deferred->retrieve_all ) {
+        print $deferred->id(),") ",$deferred->message->subject(),"\n";
     }
 };
 
 
-=head2 resume-deferred member_id deferred_id
+=head2 resume-deferred deferred_id
 
 Resume a deferred message.
 
 =cut
 
 $commands{'resume-deferred'} = sub {
-    my $user_id = shift || die "You must pass a user name\n";
     my $mess_id = shift;
 
     my $message = Siesta::Deferred->retrieve($mess_id)
       or die "No such deferred message\n";
-    return unless $user_id == $message->who;
 
-    Siesta::Message->resume( $message->id );
+    Siesta::Message->resume( $mess_id );
 
     print "Sucessfully resumed message $mess_id\n";
 };

Modified: trunk/siesta/t/30nacho.t
===================================================================
--- trunk/siesta/t/30nacho.t	2003-08-11 18:12:23 UTC (rev 1315)
+++ trunk/siesta/t/30nacho.t	2003-08-12 11:47:04 UTC (rev 1316)
@@ -1,7 +1,7 @@
 #!perl -w
 use strict;
 # use Test::More skip_all => 'nacho in a state of flux';
-use Test::More tests => 15;
+use Test::More tests => 22;
 use lib qw(t/lib);
 use Siesta::Test 'init_db';
 use Siesta::List;
@@ -69,3 +69,48 @@
 
 is_deeply( [ map { $_->name } $list->plugins ],
            [ qw( SimpleSig MembersOnly Send ) ], "specified set of plugins" );
+
+
+# deferral testing
+
+my $user = Siesta::Member->find_or_create({ email => 'test@foo' });
+
+my $message = Siesta::Message->new(\*DATA);
+ok( $message, "made a message from DATA" );
+is( $message->subject, "yoohoo", "  on which the subject is correct" );
+
+my $deferred = 
+my @deferred = Siesta::Deferred->retrieve_all;
+is( scalar @deferred, 0, "we have no deferred messages" );
+
+my $id = $message->defer(
+    why => 'the hell of it',
+    who => $user,
+   )->id;
+ok( $id, "deferred a message $id" );
+
+@deferred = Siesta::Deferred->retrieve_all;
+is( scalar @deferred, 1, "we have 1 deferred message" );
+
+system @NACHO, ('resume-deferred', $id);
+is( $?, 0, "resumed the message" );
+
+
+my @ndeferred = Siesta::Deferred->retrieve_all;
+is( scalar @ndeferred, 0, "we have no deferred messages again" );
+
+
+__DATA__
+From: jay@xxxxxxxx.xxxxxxxxxx
+To: dealers@xxxxxxxx.xxxxxxxxxx
+Subject: yoohoo
+
+All you motherfuckers are gonna pay, You are the ones who are the
+ball-lickers.  We're gonna fuck your mothers while you watch and cry
+like little bitches.  Once we get to Hollywood and find those Miramax
+fucks who are making that movie, we're gonna make 'em eat our shit,
+then shit out our shit, then eat their shit which is made up of our
+shit that we made 'em eat.  Then you're all fucking next.
+
+Love, Jay and Silent Bob.
+

Generated at 13:57 on 01 Jul 2004 by mariachi 0.52