/usr/share/perl5/KiokuDB/Test/Fixture/CAS.pm is in libkiokudb-perl 0.57-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | package KiokuDB::Test::Fixture::CAS;
BEGIN {
$KiokuDB::Test::Fixture::CAS::AUTHORITY = 'cpan:NUFFIN';
}
$KiokuDB::Test::Fixture::CAS::VERSION = '0.57';
use Moose;
use Test::More;
use Scalar::Util qw(weaken);
use KiokuDB::Test::Digested;
use namespace::clean -except => 'meta';
with qw(KiokuDB::Test::Fixture);
sub create {
my $self = shift;
KiokuDB::Test::Digested->new(
foo => "pizza",
);
}
sub verify {
my $self = shift;
$self->no_live_objects;
my $l = $self->directory->live_objects;
my $cache = $l->cache;
my $old_value = $l->leak_tracker;
my $reset = Scope::Guard->new(sub {
if ( $old_value ) {
$l->leak_tracker($old_value);
} else {
$l->clear_leak_tracker;
}
});
$l->leak_tracker(sub {
my $i = $Test::Builder::Level || 1;
$i++ until (caller($i))[1] eq __FILE__;
local $Test::Builder::Level = $i + 2;
fail("no leaks");
diag("leaked @_"),
});
my $id = $self->populate_ids->[0];
$self->txn_lives(sub {
my $obj = $self->lookup_ok($id);
is( $obj->digest, $id, "id is object digest" );
is( $obj->foo, "pizza", "field retained" );
});
if ( $cache ) {
isa_ok( my $cached = $cache->get($id), "KiokuDB::Test::Digested", "cached object" );
$self->live_objects_are($cached);
$cache->clear;
}
$self->no_live_objects();
$self->txn_lives(sub {
# test idempotent insertions
$self->insert_ok( KiokuDB::Test::Digested->new( foo => "pizza" ) );
});
$cache->clear if $cache;
$self->no_live_objects();
$self->txn_lives(sub {
my $obj = $self->lookup_ok($id);
my $new_id = $self->insert_ok( $obj->clone );
local $TODO = "ID not yet returned";
is( $new_id, $id, "idempotent add when instance already live" );
});
$cache->clear if $cache;
$self->no_live_objects();
$self->txn_lives(sub {
my $obj = $self->lookup_ok($id);
my $new_id = $self->insert_ok( $obj->clone( bar => "blah" ) );
ok( $new_id, "got a new ID" );
isnt( $new_id, $id, "idempotent add when instance already live" );
});
if ( $cache ) {
isa_ok( my $cached = $cache->get($id), "KiokuDB::Test::Digested", "cached object" );
$self->live_objects_are($cached);
$cache->clear;
}
$self->no_live_objects();
}
__PACKAGE__->meta->make_immutable;
__PACKAGE__
__END__
=pod
=encoding UTF-8
=head1 NAME
KiokuDB::Test::Fixture::CAS
=head1 VERSION
version 0.57
=head1 AUTHOR
Yuval Kogman <nothingmuch@woobling.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Yuval Kogman, Infinity Interactive.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|