my
$labelprefix
=
'add collection, alter=>0'
;
my
$test
=new autodbTestObject(
%test_args
,
labelprefix
=>
"$labelprefix:"
);
my
$object
=new Place(
name
=>
'test object original'
,
id
=>id_next());
my
(
$action
)=
@ARGV
;
if
(
$action
=~/^s/i) {
report_pass(drop_all(),
"$labelprefix: database empty"
);
my
$autodb
=
eval
{new Class::AutoDB(
database
=>testdb)};
is($@,
''
,
"$labelprefix: database created"
);
my
$correct_tables
=correct_tables(
qw(Place)
);
ok_dbtables(
$correct_tables
,
"$labelprefix: NewColl not there, as expected"
);
$test
->test_put(
object
=>
$object
,
correct_diffs
=>1);
}
elsif
(
$action
=~/^t/i) {
my
$autodb
=
eval
{new Class::AutoDB(
database
=>testdb,
alter
=>0)};
like($@,
qr/memory registry adds/
,
"$labelprefix: new failed as expected"
);
my
$correct_tables
=correct_tables(
qw(Place)
);
ok_dbtables(
$correct_tables
,
"$labelprefix: tables. NewColl not added as expected"
);
my
$correct_columns
=correct_columns(
qw(Place)
);
ok_dbcolumns(
$correct_columns
,
"$labelprefix: columns"
);
$test
->test_get(
get_args
=>{
collection
=>
'Place'
},
correct_object
=>
$object
);
}
else
{
fail(
"test requires 'action' parameter to be 'setup' or 'test'"
);
}
done_testing();