X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F89dbicadmin.t;h=80776641af728ebd5867df8c1f9307b8191be349;hb=1bc193ac4c3bb934d1877e49bf7c465fc82815d6;hp=4914f4632bb62f0de4aa8154d8c21711f1def814;hpb=5d61f42085d9c047b8a986e3aee4fa9aff055a1a;p=dbsrgits%2FDBIx-Class.git diff --git a/t/89dbicadmin.t b/t/89dbicadmin.t index 4914f46..8077664 100644 --- a/t/89dbicadmin.t +++ b/t/89dbicadmin.t @@ -8,8 +8,8 @@ use DBICTest; my $schema = DBICTest->init_schema(); -eval 'require JSON'; -plan skip_all => 'Install JSON to run this test' if ($@); +eval 'require JSON::Any'; +plan skip_all => 'Install JSON::Any to run this test' if ($@); eval 'require Text::CSV_XS'; if ($@) { @@ -19,26 +19,31 @@ if ($@) { plan tests => 5; -# double quotes round the arguments and single-quote within to make sure the -# tests run on windows as well +# the script supports double quotes round the arguments and single-quote within +# to make sure it runs on windows as well, but only if JSON::Any picks the right module + + my $employees = $schema->resultset('Employee'); -my $cmd = qq|$^X script/dbicadmin --schema=DBICTest::Schema --class=Employee --tlibs --connect="['dbi:SQLite:dbname=t/var/DBIxClass.db','','',{AutoCommit:1}]" --force --tlibs|; +my @cmd = ($^X, qw|script/dbicadmin --quiet --schema=DBICTest::Schema --class=Employee --tlibs|, q|--connect=["dbi:SQLite:dbname=t/var/DBIxClass.db","","",{"AutoCommit":1}]|, qw|--force --tlibs|); -`$cmd --op=insert --set="{name:'Matt'}"`; +system(@cmd, qw|--op=insert --set={"name":"Matt"}|); ok( ($employees->count()==1), 'insert count' ); my $employee = $employees->find(1); ok( ($employee->name() eq 'Matt'), 'insert valid' ); -`$cmd --op=update --set="{name:'Trout'}"`; +system(@cmd, qw|--op=update --set={"name":"Trout"}|); $employee = $employees->find(1); ok( ($employee->name() eq 'Trout'), 'update' ); -`$cmd --op=insert --set="{name:'Aran'}"`; -my $data = `$cmd --op=select --attrs="{order_by:'name'}"`; +system(@cmd, qw|--op=insert --set={"name":"Aran"}|); + +open(my $fh, "-|", @cmd, qw|--op=select --attrs={"order_by":"name"}|) or die $!; +my $data = do { local $/; <$fh> }; +close($fh); ok( ($data=~/Aran.*Trout/s), 'select with attrs' ); -`$cmd --op=delete --where="{name:'Trout'}"`; +system(@cmd, qw|--op=delete --where={"name":"Trout"}|); ok( ($employees->count()==1), 'delete' );