From: Tomas Doran Date: Sat, 5 Sep 2009 15:16:48 +0000 (+0000) Subject: Basic tests for ScriptRunner, more needed X-Git-Tag: 5.80014_02~58 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=c9105896143ee10916cf4ad44d3c10bad27ab02d Basic tests for ScriptRunner, more needed --- diff --git a/TODO.scripts b/TODO.scripts index b178ccf..f6a69c0 100644 --- a/TODO.scripts +++ b/TODO.scripts @@ -1,5 +1,6 @@ * Fix the fucking help to be consistent again! * Documentation * Proper test of all the options on all the scripts -* Tests for ScriptRunner +* ScriptRunner tests for MyApp::Script::DoesNotCompile + * Tests for Scripts / Role diff --git a/t/lib/Catalyst/Script/Bar.pm b/t/lib/Catalyst/Script/Bar.pm new file mode 100644 index 0000000..18e699c --- /dev/null +++ b/t/lib/Catalyst/Script/Bar.pm @@ -0,0 +1,9 @@ +package Catalyst::Script::Bar; +use Moose; +use namespace::autoclean; + +with 'Catalyst::ScriptRole'; + +sub run { __PACKAGE__ } + +1; diff --git a/t/lib/Catalyst/Script/Baz.pm b/t/lib/Catalyst/Script/Baz.pm new file mode 100644 index 0000000..d699fe6 --- /dev/null +++ b/t/lib/Catalyst/Script/Baz.pm @@ -0,0 +1,16 @@ +package Catalyst::Script::Baz; +use Moose; +use namespace::autoclean; + +use Test::More; + +with 'Catalyst::ScriptRole'; + +sub run { __PACKAGE__ } + +after new_with_options => sub { + my ($self, %args) = @_; + is_deeply \%args, { application_name => 'ScriptTestApp' }, 'App name correct'; +}; + +1; diff --git a/t/lib/ScriptTestApp/Script/Bar.pm b/t/lib/ScriptTestApp/Script/Bar.pm new file mode 100644 index 0000000..1d01fad --- /dev/null +++ b/t/lib/ScriptTestApp/Script/Bar.pm @@ -0,0 +1,9 @@ +package ScriptTestApp::Script::Bar; +use Moose; +use namespace::autoclean; + +with 'Catalyst::ScriptRole'; + +sub run { __PACKAGE__ } + +1; \ No newline at end of file diff --git a/t/lib/ScriptTestApp/Script/Foo.pm b/t/lib/ScriptTestApp/Script/Foo.pm new file mode 100644 index 0000000..8d61c63 --- /dev/null +++ b/t/lib/ScriptTestApp/Script/Foo.pm @@ -0,0 +1,9 @@ +package ScriptTestApp::Script::Foo; +use Moose; +use namespace::autoclean; + +with 'Catalyst::ScriptRole'; + +sub run { __PACKAGE__ } + +1; diff --git a/t/unit_core_scriptrunner.t b/t/unit_core_scriptrunner.t new file mode 100644 index 0000000..b87afeb --- /dev/null +++ b/t/unit_core_scriptrunner.t @@ -0,0 +1,16 @@ +use strict; +use warnings; +use Test::More tests => 5; +use FindBin qw/$Bin/; +use lib "$Bin/lib"; + +use_ok('Catalyst::ScriptRunner'); + +is Catalyst::ScriptRunner->run('ScriptTestApp', 'Foo'), 'ScriptTestApp::Script::Foo', + 'Script existing only in app'; +is Catalyst::ScriptRunner->run('ScriptTestApp', 'Bar'), 'ScriptTestApp::Script::Bar', + 'Script existing in both app and Catalyst - prefers app'; +is Catalyst::ScriptRunner->run('ScriptTestApp', 'Baz'), 'Catalyst::Script::Baz', + 'Script existing only in Catalyst'; +# +1 test for the params passed to new_with_options in t/lib/Catalyst/Script/Baz.pm +