plan
tests
=> 20;
AnnoCPAN::DBI::Note->retrieve_all->delete_all;
my
$distver
= AnnoCPAN::DBI::DistVer->retrieve(
path
=>
'authors/id/A/AL/ALICE/My-Dist-0.10.tar.gz'
);
isa_ok (
$distver
,
'AnnoCPAN::DBI::DistVer'
);
my
(
$podver
) =
$distver
->podvers;
isa_ok (
$podver
,
'AnnoCPAN::DBI::PodVer'
);
my
$pod
=
$podver
->pod;
isa_ok (
$pod
,
'AnnoCPAN::DBI::Pod'
);
my
$section
= AnnoCPAN::DBI::Section->retrieve(
podver
=>
$podver
,
pos
=> 6);
isa_ok (
$section
,
'AnnoCPAN::DBI::Section'
);
my
$note
= AnnoCPAN::DBI::Note->create({
pod
=>
$pod
,
note
=>
'hi, mom!'
,
ip
=>
'123.123.123.123'
,
time
=> 1000000000,
section
=>
$section
,
});
wait
;
isa_ok (
$note
,
'AnnoCPAN::DBI::Note'
,
'new note'
);
my
@notes
= AnnoCPAN::DBI::Note->retrieve_all;
is (
scalar
@notes
, 1,
'one note in the db'
);
my
@notepos
= AnnoCPAN::DBI::NotePos->retrieve_all;
is (
scalar
@notepos
, 6,
'translated to every section'
);
my
$dup_note
= AnnoCPAN::DBI::Note->create({
pod
=>
$pod
,
note
=>
'hi, mom!'
,
ip
=>
'123.123.123.123'
,
time
=> 1000000001,
section
=>
$section
,
});
ok ( !
$dup_note
,
'dup note'
);
@notes
= AnnoCPAN::DBI::Note->retrieve_all;
is (
scalar
@notes
, 1,
'still one note in the db'
);
@notepos
= AnnoCPAN::DBI::NotePos->retrieve_all;
is (
scalar
@notepos
, 6,
'still only once per section'
);
my
%sections
= (
qw(
authors/id/A/AL/ALICE/My-Dist-0.40.zip 7
authors/id/A/AL/ALICE/My-Dist-0.50.tar.gz 6
authors/id/A/AL/ALICE/My-Dist-0.10.tar.gz 6
authors/id/A/AL/ALICE/My-Dist-0.20.tar.gz 6
authors/id/A/AL/ALICE/My-Dist-0.30.tar.gz 7
authors/id/B/BO/BOB/My-Dist-0.20.tar.gz 6
)
);
my
@sections
=
$note
->sections;
for
my
$sect
(
@sections
) {
my
(
$pos
,
$path
) = (
$sect
->
pos
,
$sect
->podver->distver->path);
is (
$pos
,
$sections
{
$path
},
"notepos($path)"
);
}
$note
->
delete
;
@notes
= AnnoCPAN::DBI::Note->retrieve_all;
is (
scalar
@notes
, 0,
'no notes left after deleting'
);
@notepos
= AnnoCPAN::DBI::NotePos->retrieve_all;
is (
scalar
@notepos
, 0,
'all links deleted'
);
$note
= AnnoCPAN::DBI::Note->create({
pod
=>
$pod
,
note
=>
'hello, world'
,
ip
=>
'123.123.123.123'
,
time
=> 1000000002,
section
=>
$section
,
});
wait
;
@notes
= AnnoCPAN::DBI::Note->retrieve_all;
is (
scalar
@notes
, 1,
'one note in the db (again)'
);
@notepos
= AnnoCPAN::DBI::NotePos->retrieve_all;
is (
scalar
@notepos
, 6,
'once per section'
);