From 2340f08919962775cd28d9613cbd7f2665bda61b Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 22 May 2011 21:14:54 -0700 Subject: Mess around with test data --- t/data/hook_data.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 't/data/hook_data.yml') diff --git a/t/data/hook_data.yml b/t/data/hook_data.yml index da5b78f..401f6c4 100644 --- a/t/data/hook_data.yml +++ b/t/data/hook_data.yml @@ -16,8 +16,8 @@ commits: removed: [] timestamp: 2010-09-23T08:04:42-07:00 - url: https://github.com/franckcuny/Dancer/commit/22116bcdb229c1514f3069aaaf9c87e9d5455409 -compare: https://github.com/franckcuny/Dancer/compare/db8d023...22116bc + url: https://github.com/franckcuny/testing/commit/22116bcdb229c1514f3069aaaf9c87e9d5455409 +compare: https://github.com/franckcuny/testing/compare/db8d023...22116bc forced: !!perl/scalar:JSON::XS::Boolean 0 pusher: email: franck@lumberjaph.net @@ -32,12 +32,12 @@ repository: has_issues: !!perl/scalar:JSON::XS::Boolean 0 has_wiki: !!perl/scalar:JSON::XS::Boolean 1 homepage: '' - name: Dancer + name: testing open_issues: 0 owner: email: franck@lumberjaph.net name: franckcuny private: !!perl/scalar:JSON::XS::Boolean 1 pushed_at: 2010/09/23 08:04:49 -0700 - url: ./t/data/testing.git + url: ./t/data/testing watchers: 1 -- cgit 1.4.1 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 --- Build.PL | 35 ++++++++++++++++++--------------- t/003_hook_route.t | 10 +++++----- t/008_git_clone.t | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ t/data/hook_data.yml | 3 +-- 4 files changed, 80 insertions(+), 23 deletions(-) create mode 100644 t/008_git_clone.t (limited to 't/data/hook_data.yml') diff --git a/Build.PL b/Build.PL index ad985f4..a1b2814 100644 --- a/Build.PL +++ b/Build.PL @@ -15,22 +15,25 @@ my $builder = Module::Build->new( 'Test::MockObject'=> 0, }, requires => { - 'YAML' => 0, - 'Dancer' => 1.1810, - 'XML::Feed' => 0, - 'DateTime' => 0, - 'JSON' => 0, - 'YAML' => 0, - 'Dancer::Template::Xslate' => 0, - 'Dancer::Plugin::DBIC' => 0, - 'DBIx::Class' => 0, - 'DateTime::Format::SQLite' => 0, - 'SQL::Translator' => 0, - 'Digest::MD5' => 0, - 'App::perlbrew' => 0, - 'Dist::Zilla' => 0, - 'Email::Stuff' => 0, - 'Time::Elapsed' => 0, + 'autodie' => 0, + 'IPC::System::Simple' => 0, + 'IPC::Cmd' => 0, + 'YAML' => 0, + 'Dancer' => 1.1810, + 'XML::Feed' => 0, + 'DateTime' => 0, + 'JSON' => 0, + 'YAML' => 0, + 'Dancer::Template::Xslate' => 0, + 'Dancer::Plugin::DBIC' => 0, + 'DBIx::Class' => 0, + 'DateTime::Format::SQLite' => 0, + 'SQL::Translator' => 0, + 'Digest::MD5' => 0, + 'App::perlbrew' => 0, + 'Dist::Zilla' => 0, + 'Email::Stuff' => 0, + 'Time::Elapsed' => 0, 'DBIx::Class::DeploymentHandler' => 0, }, add_to_cleanup => [ 'jitterbug-', catfile(qw/t data jitterbug.db/) ], 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