fixed invalid value for param test to succeed with newer DBIx::Class versions
Alexander Hartmaier [Tue, 19 Apr 2011 15:13:01 +0000 (17:13 +0200)]
Changes
t/rpc/create.t

diff --git a/Changes b/Changes
index 6c76114..6b9e2a6 100644 (file)
--- a/Changes
+++ b/Changes
@@ -3,6 +3,7 @@ Revision history for Catalyst-Controller-DBIC-API: {{ $dist->version }}
 {{ $NEXT }}
 
 - Added has_errors method
+- Fixed tests to succeed with newer DBIx::Class versions
 
 2.003001  2011-02-16 17:52:37 Europe/Vienna
 
index 7d7fe41..f2757a3 100644 (file)
@@ -102,15 +102,25 @@ my $producer_create_url   = "$base/api/rpc/producer/create";
 
 # test create returns an error as expected when passing invalid value
 {
-    my $long_string = '-' x 1024;
+    my $data = {
+        producerid => 100,
+        name       => 'Producer',
+    };
 
-    my $req = POST(
-        $producer_create_url,
-        {   producerid => $long_string,
-            name       => $long_string,
-        },
-        'Accept' => 'text/json'
+    my $req = POST($producer_create_url, $data, 'Accept' => 'text/json');
+    $mech->request( $req, $content_type );
+    cmp_ok( $mech->status, '==', 200, 'create with pk value ok' );
+    my $response = $json->decode( $mech->content );
+    is_deeply(
+        $response,
+        { success => 'true', list => $data },
+        'json for producer with pk value ok'
     );
+    # try to insert same data again, as this seems to be the only way to
+    # force an insert to fail for SQLite.
+    # It accepts too long columns as well as wrong datatypes without errors.
+    # The bind with datatype of newer DBIC versions numifies non-integer
+    # values passed as pk value too.
     $mech->request( $req, $content_type );
     cmp_ok( $mech->status, '==', 400, 'invalid param value produces error' );
 }