[Rt-commit] r5905 - in commitbit: lib/CommitBit t

clkao at bestpractical.com clkao at bestpractical.com
Mon Sep 11 11:38:13 EDT 2006


Author: clkao
Date: Mon Sep 11 11:38:13 2006
New Revision: 5905

Added:
   commitbit/lib/CommitBit/Test.pm   (contents, props changed)
Modified:
   commitbit/lib/CommitBit/Model/Repository.pm
   commitbit/t/00-model-Repository.t

Log:
basic repository model tests.

Modified: commitbit/lib/CommitBit/Model/Repository.pm
==============================================================================
--- commitbit/lib/CommitBit/Model/Repository.pm	(original)
+++ commitbit/lib/CommitBit/Model/Repository.pm	Mon Sep 11 11:38:13 2006
@@ -10,8 +10,10 @@
 use CommitBit::Record schema {
 
         column name =>
-            type is 'text';
-        column path => 
+            type is 'text',
+            is distinct;
+            is mandatory;
+        column path =>
             type is 'text';
         column description =>
             type is 'text',
@@ -91,7 +93,7 @@
     my $args = { @_ };
     my $prefix = abs_path( Jifty->config->app("repository_prefix") );
 
-    unless (length $args->{path}) {
+    unless (exists $args->{path} and length $args->{path}) {
 	$args->{path} = File::Spec->catdir($prefix, $args->{name});
     }
 

Added: commitbit/lib/CommitBit/Test.pm
==============================================================================
--- (empty file)
+++ commitbit/lib/CommitBit/Test.pm	Mon Sep 11 11:38:13 2006
@@ -0,0 +1,37 @@
+use warnings;
+use strict;
+
+
+package CommitBit::Test;
+
+=head2 NAME
+
+CommitBit::Test
+
+=head2 DESCRIPTION
+
+This class defines helper functions for testing BTDT.
+
+=cut
+
+use base qw/Jifty::Test/;
+
+sub test_config {
+    my $class = shift;
+    my ($config) = @_;
+
+    my $hash = $class->SUPER::test_config($config);
+    $hash->{application}{repository_prefix} = 'repos-test';
+    return $hash;
+}
+
+use File::Path;
+
+sub setup {
+    my $class = shift;
+    $class->SUPER::setup;
+    rmtree ['repos-test'];
+    mkpath ['repos-test'];
+}
+
+1;

Modified: commitbit/t/00-model-Repository.t
==============================================================================
--- commitbit/t/00-model-Repository.t	(original)
+++ commitbit/t/00-model-Repository.t	Mon Sep 11 11:38:13 2006
@@ -8,7 +8,7 @@
 
 =cut
 
-use Jifty::Test tests => 11;
+use CommitBit::Test tests => 9;
 
 # Make sure we can load the model
 use_ok('CommitBit::Model::Repository');
@@ -19,31 +19,21 @@
 
 # Try testing a create
 my $o = CommitBit::Model::Repository->new(current_user => $system_user);
-my ($id) = $o->create();
+my ($id) = $o->create( name => 'test');
 ok($id, "Repository create returned success");
 ok($o->id, "New Repository has valid id set");
 is($o->id, $id, "Create returned the right id");
+ok(-e "repos-test/test/format", 'svn repository created');
 
 # And another
-$o->create();
-ok($o->id, "Repository create returned another value");
-isnt($o->id, $id, "And it is different from the previous one");
+($id) = $o->create( name => 'test');
+ok(!$id, 'distinct');
 
 # Searches in general
 my $collection =  CommitBit::Model::RepositoryCollection->new(current_user => $system_user);
 $collection->unlimit;
-is($collection->count, 2, "Finds two records");
+is($collection->count, 1, "Finds two records");
 
 # Searches in specific
 $collection->limit(column => 'id', value => $o->id);
 is($collection->count, 1, "Finds one record with specific id");
-
-# Delete one of them
-$o->delete;
-$collection->redo_search;
-is($collection->count, 0, "Deleted row is gone");
-
-# And the other one is still there
-$collection->unlimit;
-is($collection->count, 1, "Still one left");
-


More information about the Rt-commit mailing list