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 | |
0ffbc9ec |
22 | # double quotes round the arguments and single-quote within to make sure the |
23 | # tests run on windows as well |
24 | |
70350518 |
25 | my $employees = $schema->resultset('Employee'); |
5d61f420 |
26 | my $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 |
29 | ok( ($employees->count()==1), 'insert count' ); |
d8d6276a |
30 | |
70350518 |
31 | my $employee = $employees->find(1); |
32 | ok( ($employee->name() eq 'Matt'), 'insert valid' ); |
d8d6276a |
33 | |
0ffbc9ec |
34 | `$cmd --op=update --set="{name:'Trout'}"`; |
70350518 |
35 | $employee = $employees->find(1); |
36 | ok( ($employee->name() eq 'Trout'), 'update' ); |
d8d6276a |
37 | |
0ffbc9ec |
38 | `$cmd --op=insert --set="{name:'Aran'}"`; |
39 | my $data = `$cmd --op=select --attrs="{order_by:'name'}"`; |
70350518 |
40 | ok( ($data=~/Aran.*Trout/s), 'select with attrs' ); |
41 | |
0ffbc9ec |
42 | `$cmd --op=delete --where="{name:'Trout'}"`; |
70350518 |
43 | ok( ($employees->count()==1), 'delete' ); |
d8d6276a |
44 | |