Patch for ? in NoBindVars data from Tom Hukins
[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
0ffbc9ec 22# double quotes round the arguments and single-quote within to make sure the
23# tests run on windows as well
24
70350518 25my $employees = $schema->resultset('Employee');
5d61f420 26my $cmd = qq|$^X script/dbicadmin --schema=DBICTest::Schema --class=Employee --tlibs --connect="['dbi:SQLite:dbname=t/var/DBIxClass.db','','',{AutoCommit:1}]" --force --tlibs|;
d8d6276a 27
0ffbc9ec 28`$cmd --op=insert --set="{name:'Matt'}"`;
70350518 29ok( ($employees->count()==1), 'insert count' );
d8d6276a 30
70350518 31my $employee = $employees->find(1);
32ok( ($employee->name() eq 'Matt'), 'insert valid' );
d8d6276a 33
0ffbc9ec 34`$cmd --op=update --set="{name:'Trout'}"`;
70350518 35$employee = $employees->find(1);
36ok( ($employee->name() eq 'Trout'), 'update' );
d8d6276a 37
0ffbc9ec 38`$cmd --op=insert --set="{name:'Aran'}"`;
39my $data = `$cmd --op=select --attrs="{order_by:'name'}"`;
70350518 40ok( ($data=~/Aran.*Trout/s), 'select with attrs' );
41
0ffbc9ec 42`$cmd --op=delete --where="{name:'Trout'}"`;
70350518 43ok( ($employees->count()==1), 'delete' );
d8d6276a 44