Commit | Line | Data |
d8d6276a |
1 | # vim: filetype=perl |
70350518 |
2 | use strict; |
3 | use warnings; |
d8d6276a |
4 | |
70350518 |
5 | use Test::More; |
6 | use lib qw(t/lib); |
7 | use DBICTest; |
d8d6276a |
8 | |
a47e1233 |
9 | my $schema = DBICTest->init_schema(); |
d8d6276a |
10 | |
70350518 |
11 | eval 'require JSON'; |
12 | plan skip_all => 'Install JSON to run this test' if ($@); |
d8d6276a |
13 | |
70350518 |
14 | eval 'require Text::CSV_XS'; |
15 | if ($@) { |
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 |
20 | plan tests => 5; |
d8d6276a |
21 | |
70350518 |
22 | my $employees = $schema->resultset('Employee'); |
23 | my $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"}'`; |
26 | ok( ($employees->count()==1), 'insert count' ); |
d8d6276a |
27 | |
70350518 |
28 | my $employee = $employees->find(1); |
29 | ok( ($employee->name() eq 'Matt'), 'insert valid' ); |
d8d6276a |
30 | |
70350518 |
31 | `$cmd --op=update --set='{name:"Trout"}'`; |
32 | $employee = $employees->find(1); |
33 | ok( ($employee->name() eq 'Trout'), 'update' ); |
d8d6276a |
34 | |
70350518 |
35 | `$cmd --op=insert --set='{name:"Aran"}'`; |
36 | my $data = `$cmd --op=select --attrs='{order_by:"name"}'`; |
37 | ok( ($data=~/Aran.*Trout/s), 'select with attrs' ); |
38 | |
39 | `$cmd --op=delete --where='{name:"Trout"}'`; |
40 | ok( ($employees->count()==1), 'delete' ); |
d8d6276a |
41 | |