Commit | Line | Data |
d8d6276a |
1 | # vim: filetype=perl |
2 | |
3 | sub run_tests { |
4 | |
4527bbdc |
5 | eval 'require JSON'; |
d8d6276a |
6 | plan skip_all, 'Install JSON to run this test' if ($@); |
7 | |
4527bbdc |
8 | eval 'require Text::CSV_XS'; |
d8d6276a |
9 | if ($@) { |
4527bbdc |
10 | eval 'require Text::CSV_PP'; |
d8d6276a |
11 | plan skip_all, 'Install Text::CSV_XS or Text::CSV_PP to run this test' if ($@); |
12 | } |
13 | |
14 | plan tests => 5; |
15 | my $schema = shift; |
16 | |
17 | my $employees = $schema->resultset('Employee'); |
bed3cf65 |
18 | my $cmd = qq|script/dbicadmin --schema=DBICTest::Schema --class=Employee --tlibs --connect='["dbi:SQLite:dbname=t/var/DBIxClass.db","",""]' --force --tlibs|; |
d8d6276a |
19 | |
20 | `$cmd --op=insert --set='{name:"Matt"}'`; |
21 | ok( ($employees->count()==1), 'insert count' ); |
22 | |
23 | my $employee = $employees->find(1); |
24 | ok( ($employee->name() eq 'Matt'), 'insert valid' ); |
25 | |
26 | `$cmd --op=update --set='{name:"Trout"}'`; |
27 | $employee = $employees->find(1); |
28 | ok( ($employee->name() eq 'Trout'), 'update' ); |
29 | |
30 | `$cmd --op=insert --set='{name:"Aran"}'`; |
31 | my $data = `$cmd --op=select --attrs='{order_by:"name"}'`; |
32 | ok( ($data=~/Aran.*Trout/s), 'select with attrs' ); |
33 | |
34 | `$cmd --op=delete --where='{name:"Trout"}'`; |
35 | ok( ($employees->count()==1), 'delete' ); |
36 | } |
37 | |
38 | 1; |