fixed up sqlt tests a bit and tried fixing 2 failing sqlt tests
[dbsrgits/DBIx-Class-Historic.git] / t / 89dbicadmin.t
CommitLineData
d8d6276a 1# vim: filetype=perl
70350518 2use strict;
3use warnings;
d8d6276a 4
70350518 5use Test::More;
6use lib qw(t/lib);
7use DBICTest;
d8d6276a 8
a47e1233 9my $schema = DBICTest->init_schema();
d8d6276a 10
70350518 11eval 'require JSON';
12plan skip_all => 'Install JSON to run this test' if ($@);
d8d6276a 13
70350518 14eval 'require Text::CSV_XS';
15if ($@) {
16 eval 'require Text::CSV_PP';
17 plan skip_all => 'Install Text::CSV_XS or Text::CSV_PP to run this test' if ($@);
18}
d8d6276a 19
70350518 20plan tests => 5;
d8d6276a 21
70350518 22my $employees = $schema->resultset('Employee');
23my $cmd = qq|script/dbicadmin --schema=DBICTest::Schema --class=Employee --tlibs --connect='["dbi:SQLite:dbname=t/var/DBIxClass.db","",""]' --force --tlibs|;
d8d6276a 24
70350518 25`$cmd --op=insert --set='{name:"Matt"}'`;
26ok( ($employees->count()==1), 'insert count' );
d8d6276a 27
70350518 28my $employee = $employees->find(1);
29ok( ($employee->name() eq 'Matt'), 'insert valid' );
d8d6276a 30
70350518 31`$cmd --op=update --set='{name:"Trout"}'`;
32$employee = $employees->find(1);
33ok( ($employee->name() eq 'Trout'), 'update' );
d8d6276a 34
70350518 35`$cmd --op=insert --set='{name:"Aran"}'`;
36my $data = `$cmd --op=select --attrs='{order_by:"name"}'`;
37ok( ($data=~/Aran.*Trout/s), 'select with attrs' );
38
39`$cmd --op=delete --where='{name:"Trout"}'`;
40ok( ($employees->count()==1), 'delete' );
d8d6276a 41