about summary refs log tree commit diff
path: root/t
diff options
context:
space:
mode:
authorJonathan "Duke" Leto <jonathan@leto.net>2011-05-22 22:17:29 -0700
committerJonathan "Duke" Leto <jonathan@leto.net>2011-05-22 22:17:29 -0700
commit4b36d82c173ce6cb24f52a9e30dc08354c0af2e3 (patch)
tree98f888830595abd1f9e2a411d4c151ec35beb0af /t
parentTry adding a git repo for testing again (diff)
downloadjitterbug-4b36d82c173ce6cb24f52a9e30dc08354c0af2e3.tar.gz
Add a test file for git cloning
Diffstat (limited to 't')
-rw-r--r--t/003_hook_route.t10
-rw-r--r--t/008_git_clone.t55
-rw-r--r--t/data/hook_data.yml3
3 files changed, 61 insertions, 7 deletions
diff --git a/t/003_hook_route.t b/t/003_hook_route.t
index 0361b15..6e86dfd 100644
--- a/t/003_hook_route.t
+++ b/t/003_hook_route.t
@@ -44,7 +44,7 @@ my $response;
 }
 
 {
-    my $rs = $schema->resultset('Project')->find( { name => 'Dancer' } );
+    my $rs = $schema->resultset('Project')->find( { name => 'testing' } );
     ok !defined $rs, 'no project dancer yet';
 
     $response = dancer_response(
@@ -58,11 +58,11 @@ my $response;
 
     is $response->{status}, 200, 'status OK with payload';
     is_deeply JSON::decode_json( $response->{content} ),
-      { updated => 'Dancer' }, 'response OK with payload';
+      { updated => 'testing' }, 'response OK with payload';
 
-    $rs = $schema->resultset('Project')->find( { name => 'Dancer' } );
+    $rs = $schema->resultset('Project')->find( { name => 'testing' } );
     ok $rs, 'project exists in DB';
-    is $rs->name, 'Dancer', 'project\'s name is good';
+    is $rs->name, 'testing', 'project\'s name is good';
 
     is $schema->resultset('Task')->search()->count(), 1, 'one task created';
 }
@@ -90,7 +90,7 @@ my $response;
     $schema->resultset('Task')->search()->delete();
 
     # testing with invalid global branch
-    setting jitterbug => { branches => { Dancer => ['foo'], }, };
+    setting jitterbug => { branches => { testing => ['foo'], }, };
     $content->{ref} = 'refs/heads/foo';
     $response = dancer_response(
         POST => '/hook/',
diff --git a/t/008_git_clone.t b/t/008_git_clone.t
new file mode 100644
index 0000000..c4935ce
--- /dev/null
+++ b/t/008_git_clone.t
@@ -0,0 +1,55 @@
+use Test::More tests => 3;
+use Test::Exception;
+use strict;
+use warnings;
+use autodie qw/:all/;
+use IPC::Cmd qw/can_run/;
+
+use jitterbug;
+use jitterbug::Schema;
+use lib 't/lib';
+use jitterbug::Test;
+
+use JSON;
+use YAML qw/LoadFile Dump/;
+
+use File::Spec;
+use File::Temp qw/tempdir/;
+
+use Dancer::Test;
+use Dancer::Config qw/setting/;
+use File::Spec::Functions;
+use File::Copy::Recursive qw/dircopy/;
+my $hook_data = catfile(qw/t data hook_data.yml/);
+
+my $content = LoadFile($hook_data);
+
+my $db_dir = tempdir( CLEANUP => 1 );
+my $db_file = File::Spec->catfile( $db_dir, 'jitterbug.db' );
+my $dsn     = 'dbi:SQLite:dbname=' . $db_file;
+my $schema  = jitterbug::Schema->connect($dsn);
+$schema->deploy;
+
+setting plugins => {
+    DBIC => {
+        schema => {
+            skip_automake => 1,
+            pckg          => "jitterbug::Schema",
+            connect_info  => [$dsn]
+        }
+    }
+};
+
+if (can_run('git')){
+
+    my $gitrepo = "t/data/testing";
+    dircopy "$gitrepo/._git_", "$gitrepo/.git" unless -e "$gitrepo/.git";
+
+    lives_ok sub { system("$^X scripts/post_to_hook.pl") }, 'post_to_hook.pl lives';
+
+    lives_ok sub { system("$^X scripts/builder.pl -c t/data/test.yml -C") }, 'builder.pl lives';
+
+    ok(-e "t/tmp/build/testing/.git", 'found a testing git repo');
+} else {
+    skip "Git not available, skipping tests", 3;
+}
diff --git a/t/data/hook_data.yml b/t/data/hook_data.yml
index 401f6c4..a55d7e9 100644
--- a/t/data/hook_data.yml
+++ b/t/data/hook_data.yml
@@ -8,8 +8,7 @@ commits:
     author: 
       email: franck@lumberjaph.net
       name: franck cuny
-    #id: 8c3c1d6be0fa27ada4f03258ddea7683c967a925
-    id: ba54d9b7d82eabe4ba35ec212eb24d00869119d5
+    id: 3ab75b9a29e09bf027f64250b44cab19b316c128
     message: test
     modified: 
       - lib/Dancer.pm