X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F89dbicadmin.t;h=095204d5bc57ff17168c9a520111b3c89af39daf;hb=20ea4813ff750408ceb3b9701bf9e88dc6bcff78;hp=7c7a89cad8521ca7d875eb79d9e2fe2858a002d1;hpb=50db197ee7b4407bc6aad1dfa246a734b019619a;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/89dbicadmin.t b/t/89dbicadmin.t index 7c7a89c..095204d 100644 --- a/t/89dbicadmin.t +++ b/t/89dbicadmin.t @@ -6,10 +6,10 @@ use Test::More; use lib qw(t/lib); use DBICTest; -my $schema = DBICTest->init_schema(); +my $schema = DBICTest->init_schema( sqlite_use_file => 1 ); -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,23 +19,31 @@ if ($@) { plan tests => 5; +# 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|perl script/dbicadmin --schema=DBICTest::Schema --class=Employee --tlibs --connect='["dbi:SQLite:dbname=t/var/DBIxClass.db","",""]' --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' );