[Bps-public-commit] r17395 - sd/trunk/t

jesse at bestpractical.com jesse at bestpractical.com
Mon Dec 29 00:49:18 EST 2008


Author: jesse
Date: Mon Dec 29 00:49:18 2008
New Revision: 17395

Modified:
   sd/trunk/t/server.t

Log:
* server tests now use the right class...and run

Modified: sd/trunk/t/server.t
==============================================================================
--- sd/trunk/t/server.t	(original)
+++ sd/trunk/t/server.t	Mon Dec 29 00:49:18 2008
@@ -1,6 +1,7 @@
 #!/usr/bin/perl
 use warnings;
 use strict;
+use Test::HTTP::Server::Simple;
 
 BEGIN {
     use File::Temp qw(tempdir);
@@ -8,7 +9,9 @@
 
 }
 
-use Prophet::Test tests => 14;
+
+use Prophet::Test tests => 16;
+use App::SD::Server;
 use Test::WWW::Mechanize;
 use JSON;
 
@@ -23,12 +26,12 @@
 sub url {
     return join( "/", $url_root, @_ );
 }
-diag(url());
+diag( url() );
 $ua->get_ok( url('records.json') );
-is( $ua->content, '[]' );
+is( $ua->content, '["__prophet_db_settings"]' );
 
-my $t = App::SD::Model::Ticket->new(app_handle => $app_handle);
-my ($uuid) = $t->create( props => { summary => 'The server works'});
+my $t = App::SD::Model::Ticket->new( app_handle => $app_handle );
+my ($uuid) = $t->create( props => { summary => 'The server works' } );
 ok( $uuid, "Created record $uuid" );
 
 $ua->get_ok( url('records.json') );
@@ -37,9 +40,14 @@
 $ua->get_ok( url( 'records', 'ticket', $uuid . ".json" ) );
 
 TODO: {
-    local $TODO =" need to set created date";
-is( $ua->content, '{"original_replica":"'.$t->handle->uuid.'","creator":"'.$t->default_prop_creator.'","summary":"The server works","status":"new"}' );
-};
+    local $TODO = " need to set created date";
+    is( $ua->content,
+              '{"original_replica":"'
+            . $t->handle->uuid
+            . '","creator":"'
+            . $t->default_prop_creator
+            . '","summary":"The server works","status":"new"}' );
+}
 
 $ua->get( url( 'records', 'ticket', "1234.json" ) );
 is( $ua->status, '404' );
@@ -48,23 +56,31 @@
 
 $ua->get_ok( url( 'records', 'ticket', $uuid . ".json" ) );
 TODO: {
-    local $TODO =" need to set created date";
-    is( $ua->content, '{"original_replica":"'.$t->handle->uuid.'","creator":"'.$t->default_prop_creator.'","summary":"The server works","status":"new"}' );
-};
+    local $TODO = " need to set created date";
+    is( $ua->content,
+              '{"original_replica":"'
+            . $t->handle->uuid
+            . '","creator":"'
+            . $t->default_prop_creator
+            . '","summary":"The server works","status":"new"}' );
+}
+
+$ua->get_ok( url());
+like($ua->content, qr/SD for Your SD Project/);
+
+
 
 sub start_server {
-my $server_cli = Prophet::CLI->new();
-my $s   = App::SD::TestServer->new();
-$server_cli->handle()->initialize;
-$s->app_handle( $server_cli->app_handle );
-my $url_root = $s->started_ok("start up my web server");
-return $url_root;
+    my $server_cli = App::SD::CLI->new();
+    my $s          = App::SD::Server->new();
+    unshift @App::SD::Server::ISA, 'Test::HTTP::Server::Simple';
+    $server_cli->handle()->initialize;
+    $s->port(int(rand(10000)+1024));
+    $s->app_handle( $server_cli->app_handle );
+    my $url_root = $s->started_ok("start up my web server");
+    return $url_root;
 }
-package App::SD::TestServer;
-use base qw/Test::HTTP::Server::Simple Prophet::Server/;
-
 
-sub port { my $self = shift; $self->{_port} ||= int(rand(1024))+10000; return $self->{_port} }
 
 
 



More information about the Bps-public-commit mailing list