X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fadmin%2F03data.t;h=ee35001135736c2d91742ef90727054172a22690;hb=a8de639b29afc6645820ba346b47d53117dbbe7e;hp=02785af87e649718d57e91a3f8e2a7392f456e1c;hpb=9c34993a245213636c321b22ce0ff2f18aaf8d9b;p=dbsrgits%2FDBIx-Class.git diff --git a/t/admin/03data.t b/t/admin/03data.t index 02785af..ee35001 100644 --- a/t/admin/03data.t +++ b/t/admin/03data.t @@ -1,89 +1,63 @@ -# vim: et ts=2 -#=============================================================================== -# -# FILE: 03sql.t -# -# DESCRIPTION: test sql manipulation funtions -# -# FILES: --- -# BUGS: --- -# NOTES: --- -# AUTHOR: Gordon Irving (), -# VERSION: 1.0 -# CREATED: 12/12/09 12:44:57 GMT -# REVISION: --- -#=============================================================================== - use strict; use warnings; use Test::More; - use Test::Exception; -use Test::Deep; + +use lib 't/lib'; +use DBICTest; BEGIN { - eval "use DBIx::Class::Admin"; - plan skip_all => "Deps not installed: $@" if $@; + require DBIx::Class; + plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for('admin') + unless DBIx::Class::Optional::Dependencies->req_ok_for('admin'); } -use Path::Class; -use FindBin qw($Bin); - -use lib dir($Bin,'..', '..','lib')->stringify; -use lib dir($Bin,'..', 'lib')->stringify; +use_ok 'DBIx::Class::Admin'; -use ok 'DBIx::Class::Admin'; - -use DBICTest; { # test data maniplulation functions - # create a DBICTest so we can steal its connect info - my $schema = DBICTest->init_schema( - # no_deploy=>1, - # no_populate=>1, - sqlite_use_file => 1, - ); - + # create a DBICTest so we can steal its connect info + my $schema = DBICTest->init_schema( + sqlite_use_file => 1, + ); - my $admin = DBIx::Class::Admin->new( - schema_class=> "DBICTest::Schema", - connect_info => $schema->storage->connect_info(), - quiet => 1, - _confirm=>1, - ); - isa_ok ($admin, 'DBIx::Class::Admin', 'create the admin object'); + my $admin = DBIx::Class::Admin->new( + schema_class=> "DBICTest::Schema", + connect_info => $schema->storage->connect_info(), + quiet => 1, + _confirm=>1, + ); + isa_ok ($admin, 'DBIx::Class::Admin', 'create the admin object'); - $admin->insert('Employee', { name => 'Matt' }); - my $employees = $schema->resultset('Employee'); - is ($employees->count(), 1, "insert okay" ); + $admin->insert('Employee', { name => 'Matt' }); + my $employees = $schema->resultset('Employee'); + is ($employees->count(), 1, "insert okay" ); - my $employee = $employees->find(1); - is($employee->name(), 'Matt', "insert valid" ); + my $employee = $employees->find(1); + is($employee->name(), 'Matt', "insert valid" ); - $admin->update('Employee', {name => 'Trout'}, {name => 'Matt'}); + $admin->update('Employee', {name => 'Trout'}, {name => 'Matt'}); - $employee = $employees->find(1); - is($employee->name(), 'Trout', "update Matt to Trout" ); + $employee = $employees->find(1); + is($employee->name(), 'Trout', "update Matt to Trout" ); - $admin->insert('Employee', {name =>'Aran'}); + $admin->insert('Employee', {name =>'Aran'}); - my $expected_data = [ + my $expected_data = [ [$employee->result_source->columns() ], - [1,1,undef,undef,undef,'Trout'], - [2,2,undef,undef,undef,'Aran'] - ]; - my $data; - lives_ok { $data = $admin->select('Employee')} 'can retrive data from database'; - cmp_deeply($data, $expected_data, 'DB matches whats expected'); - - $admin->delete('Employee', {name=>'Trout'}); - my $del_rs = $employees->search({name => 'Trout'}); - is($del_rs->count(), 0, "delete Trout" ); - is ($employees->count(), 1, "left Aran" ); + [1,1,undef,undef,undef,'Trout',undef], + [2,2,undef,undef,undef,'Aran',undef] + ]; + my $data; + lives_ok { $data = $admin->select('Employee', undef, { order_by => 'employee_id' })} 'can retrive data from database'; + is_deeply($data, $expected_data, 'DB matches whats expected'); + + $admin->delete('Employee', {name=>'Trout'}); + my $del_rs = $employees->search({name => 'Trout'}); + is($del_rs->count(), 0, "delete Trout" ); + is ($employees->count(), 1, "left Aran" ); } - - done_testing;