From 4b36d82c173ce6cb24f52a9e30dc08354c0af2e3 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 22 May 2011 22:17:29 -0700 Subject: Add a test file for git cloning --- t/003_hook_route.t | 10 +++++----- t/008_git_clone.t | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ t/data/hook_data.yml | 3 +-- 3 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 t/008_git_clone.t (limited to 't') 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 -- cgit 1.4.1