added test for check_has_column
Alexander Hartmaier [Sun, 8 Aug 2010 13:20:57 +0000 (15:20 +0200)]
t/generic.t [new file with mode: 0644]
t/lib/TestAppCheckHasCol.pm [new file with mode: 0644]
t/lib/TestAppCheckHasCol/Controller/InvalidColumn.pm [new file with mode: 0644]
t/lib/TestAppCheckHasCol/Model/TestAppDB.pm [new file with mode: 0644]

diff --git a/t/generic.t b/t/generic.t
new file mode 100644 (file)
index 0000000..fa6a297
--- /dev/null
@@ -0,0 +1,11 @@
+use strict;
+use warnings;
+use lib 't/lib';
+use Test::More;
+
+{
+    eval "use Catalyst::Test 'TestAppCheckHasCol'";
+    like($@, qr/^Couldn't load class \(TestAppCheckHasCol\) because: Couldn't instantiate component "TestAppCheckHasCol::Controller::InvalidColumn", "Column 'foo' does not exist in ResultSet 'TestAppDB::Artist'/, 'check_has_column ok');
+}
+
+done_testing();
diff --git a/t/lib/TestAppCheckHasCol.pm b/t/lib/TestAppCheckHasCol.pm
new file mode 100644 (file)
index 0000000..5c4b101
--- /dev/null
@@ -0,0 +1,14 @@
+package TestAppCheckHasCol;
+use Moose;
+use namespace::autoclean;
+use Catalyst::Runtime 5.70;
+
+extends 'Catalyst';
+
+our $VERSION = '0.01';
+
+__PACKAGE__->config( name => __PACKAGE__ );
+
+__PACKAGE__->setup;
+
+1;
diff --git a/t/lib/TestAppCheckHasCol/Controller/InvalidColumn.pm b/t/lib/TestAppCheckHasCol/Controller/InvalidColumn.pm
new file mode 100644 (file)
index 0000000..e941a01
--- /dev/null
@@ -0,0 +1,13 @@
+package TestAppCheckHasCol::Controller::InvalidColumn;
+use Moose;
+use namespace::autoclean;
+
+extends 'Catalyst::Controller::DBIC::API::REST';
+
+__PACKAGE__->config(
+    action => { setup => { PathPart => 'undefcol', Chained => '/api/rest/rest_base' } },
+    class => 'TestAppDB::Artist',
+    update_allows => ['foo'],
+);
+
+1;
diff --git a/t/lib/TestAppCheckHasCol/Model/TestAppDB.pm b/t/lib/TestAppCheckHasCol/Model/TestAppDB.pm
new file mode 100644 (file)
index 0000000..13feb2a
--- /dev/null
@@ -0,0 +1,19 @@
+package TestAppCheckHasCol::Model::TestAppDB;
+
+use strict;
+use warnings;
+use base 'Catalyst::Model::DBIC::Schema';
+
+use Catalyst::Utils;
+
+__PACKAGE__->config(
+    schema_class => 'RestTest::Schema',
+    connect_info => [
+        "dbi:SQLite:t/var/DBIxClass.db",
+        undef,
+        undef,
+        {AutoCommit => 1}
+    ]
+);
+
+1;