| 1 | package BusyBird::Test::StatusStorage; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use v5.8.0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use Exporter 5.57 qw(import); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use DateTime; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use DateTime::Duration; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Test::More; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use Test::Builder; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use Test::Fatal 0.006 qw(dies_ok); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 7 | ▶ | use BusyBird::DateTime::Format; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use BusyBird::StatusStorage; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 7 | ▶ | use BusyBird::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 7 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 7 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 7 | ▶ | use Encode qw(encode_utf8); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 7 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | storage => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | qw(test_storage_common test_storage_ordered test_storage_truncation test_storage_missing_arguments), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | qw(test_storage_requires_status_ids test_storage_undef_in_array), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | status => [qw(test_status_id_set test_status_id_list)], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 7 | our @EXPORT_OK = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 7 | BusyBird::Util::export_ok_all_tags(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 7 | push @EXPORT_OK, qw(test_cases_for_ack); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 7 | my $datetime_formatter = 'BusyBird::DateTime::Format'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1829 | ▶ | sub status { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1829 | my ($id, $level, $acked_at) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1829 | ▶ | croak "you must specify id" if not defined $id; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1829 | my $status = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | id => $id, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | created_at => $datetime_formatter->format_datetime( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | DateTime->from_epoch(epoch => $id) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1829 | ▶ | $status->{busybird}{level} = $level if defined $level; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1829 | ▶ | $status->{busybird}{acked_at} = $acked_at if defined $acked_at; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1829 | return $status; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 84 | ▶ | sub nowstring { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nowstring: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 84 | return $datetime_formatter->format_datetime( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | DateTime->now(time_zone => 'UTC') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 150 | ▶ | sub add_datetime_days { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_datetime_days: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 150 | my ($datetime_str, $days) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 150 | ▶ | my $dtd = DateTime::Duration->new(days => ($days > 0 ? $days : -$days)); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 150 | my $orig_dt = $datetime_formatter->parse_datetime($datetime_str); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 150 | ▶ | return $datetime_formatter->format_datetime( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ($days > 0) ? ($orig_dt + $dtd) : ($orig_dt - $dtd) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1580 | ▶ | sub id_counts { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id_counts: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1580 | my @statuses_or_ids = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1580 | my %id_counts = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1580 | foreach my $s_id (@statuses_or_ids) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 17040 | ▶ | my $id = ref($s_id) ? $s_id->{id} : $s_id; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 17040 | $id_counts{$id} += 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 1580 | return %id_counts; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 844 | ▶ | sub id_list { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id_list: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 844 | my @statuses_or_ids = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 844 | ▶ | return map { ref($_) ? $_->{id} : $_ } @statuses_or_ids; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 4181 | ▶ | sub acked { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
acked: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 4181 | my ($s) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 7 | ▶ | no autovivification; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 4181 | return $s->{busybird}{acked_at}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 790 | ▶ | sub test_status_id_set { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test_status_id_set: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | ## unordered status ID set test | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 790 | my ($got_statuses, $exp_statuses_or_ids, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 790 | local $Test::Builder::Level = $Test::Builder::Level + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 790 | return is_deeply( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | { id_counts @$got_statuses }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | { id_counts @$exp_statuses_or_ids }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | $msg | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 422 | ▶ | sub test_status_id_list { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test_status_id_list: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | ## ordered status ID list test | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 422 | my ($got_statuses, $exp_statuses_or_ids, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 422 | local $Test::Builder::Level = $Test::Builder::Level + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 422 | return is_deeply( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | [id_list @$got_statuses], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | [id_list @$exp_statuses_or_ids], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | $msg | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1173 | ▶ | sub sync_get { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sync_get: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 1173 | my ($storage, $loop, $unloop, %query) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1173 | local $Test::Builder::Level = $Test::Builder::Level + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1173 | my $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 1173 | my $statuses; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 1173 | ▶ | $storage->get_statuses(%query, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1173 | my $error = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 1173 | $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1173 | is($error, undef, 'operation succeed'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1173 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 1173 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1173 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1173 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1173 | ok($callbacked, 'callbacked'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1173 | return $statuses; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 27 | ▶ | sub sync_get_unacked_counts { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sync_get_unacked_counts: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 27 | my ($storage, $loop, $unloop, $timeline) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 27 | local $Test::Builder::Level = $Test::Builder::Level + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 27 | my $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 27 | my $result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | $storage->get_unacked_counts( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 27 | ▶ | timeline => $timeline, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 27 | my ($error, $unacked_counts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 27 | is($error, undef, 'operation succeed'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 27 | $result = $unacked_counts; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 27 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 27 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 27 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 27 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 27 | ok($callbacked, 'callbacked'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 27 | return %$result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 1152 | ▶ | sub on_statuses { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_statuses: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 1152 | my ($storage, $loop, $unloop, $query_ref, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 1152 | local $Test::Builder::Level = $Test::Builder::Level + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 1152 | $code->(sync_get($storage, $loop, $unloop, %$query_ref)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 252 | ▶ | sub change_and_check { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
change_and_check: called CC=11 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 252 | my ($storage, $loop, $unloop, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 252 | my $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 252 | local $Test::Builder::Level = $Test::Builder::Level + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 252 | ▶ | my $label = "change_and_check " . ($args{label} || "") . ":"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{'label'} || ''
MC/DC100%1/1
$args{'label'} || ''
$args{'label'}
Truth table100%2/2
A
A= $args{'label'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 252 | ▶ | my $callback_func = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 252 | my ($error, $result) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 252 | is($error, undef, "$label $args{mode} succeed."); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | is($result, $args{exp_change}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 252 | "$label $args{mode} changed $args{exp_change}"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 252 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 252 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 252 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 252 | ▶ | if($args{mode} eq 'insert' || $args{mode} eq 'update' || $args{mode} eq 'upsert') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%6/6
$args{"mode"} eq "insert" or $args{"mode"} eq "update" or $args{"mode"} eq "upsert"
$args{"mode"} eq "insert" or $args{"mode"} eq "update"
MC/DC100%3/3
$args{"mode"} eq "insert" or $args{"mode"} eq "update" or $args{"mode"} eq "upsert"
$args{"mode"} eq "insert"
$args{"mode"} eq "update"
$args{"mode"} eq "upsert"
Truth table100%4/4
A or B or C
A= $args{"mode"} eq "insert"B= $args{"mode"} eq "update"C= $args{"mode"} eq "upsert"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | $storage->put_statuses( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | timeline => $args{timeline}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | mode => $args{mode}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | statuses => $args{target}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 159 | callback => $callback_func, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 159 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | }elsif($args{mode} eq 'delete') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 33 | my $method = "$args{mode}_statuses"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | my %method_args = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | timeline => $args{timeline}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 33 | callback => $callback_func, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 33 | ▶ | $method_args{ids} = $args{target} if exists($args{target}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 33 | $storage->$method(%method_args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 33 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | }elsif($args{mode} eq 'ack') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 60 | my $method = "$args{mode}_statuses"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | my %method_args = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | timeline => $args{timeline}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 60 | callback => $callback_func, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 60 | ▶ | $method_args{max_id} = $args{target} if exists($args{target}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 60 | ▶ | $method_args{max_id} = $args{target_max_id} if exists($args{target_max_id}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 60 | ▶ | $method_args{ids} = $args{target_ids} if exists($args{target_ids}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 60 | $storage->$method(%method_args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | }else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | croak "Invalid mode"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | timeline => $args{timeline}, count => 'all', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | ack_state => 'acked' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 252 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 252 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | test_status_id_set( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | $statuses, $args{exp_acked}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 252 | "$label acked statuses OK" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 252 | foreach my $s (@$statuses) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 2019 | ok(acked($s), "$label acked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 252 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | timeline => $args{timeline}, count => 'all', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | ack_state => 'unacked', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 252 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 252 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | test_status_id_set( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | $statuses, $args{exp_unacked}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 252 | "$label unacked statuses OK" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 252 | foreach my $s (@$statuses) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 2144 | ok(!acked($s), "$label not acked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 252 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | timeline => $args{timeline}, count => 'all', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | ack_state => 'any', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 252 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 252 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | test_status_id_set( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 252 | $statuses, [@{$args{exp_acked}}, @{$args{exp_unacked}}], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | "$label statuses in any state OK" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 252 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 174 | ▶ | sub get_and_check_list { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_and_check_list: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 174 | my ($storage, $loop, $unloop, $get_args, $exp_id_list, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 174 | local $Test::Builder::Level = $Test::Builder::Level + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 174 | ▶ | on_statuses $storage, $loop, $unloop, $get_args, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 174 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 174 | test_status_id_list $statuses, $exp_id_list, $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 174 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 12 | ▶ | sub test_cases_for_ack { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test_cases_for_ack: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | ## ** assumption: acked [1..10] (sufficiently old), unacked [11..20] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 12 | my (%args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 12 | ▶ | if($args{is_ordered}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 4 | {label => 'max_id', req => {max_id => 14}, exp_count => 4, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | exp_unacked => [reverse 15..20], exp_acked => [reverse 1..14]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | {label => 'max_id with ids < max_id', req => {ids => 12, max_id => 15}, exp_count => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | exp_unacked => [reverse 16..20], exp_acked => [reverse 1..15]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | {label => 'max_id with ids > max_id', req => {ids => [15,17], max_id => 13}, exp_count => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | exp_unacked => [reverse 14,16,18..20], exp_acked => [reverse 1..13,15,17]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | {label => 'max_id with ids = max_id', req => {ids => 15, max_id => 15}, exp_count => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | exp_unacked => [reverse 16..20], exp_acked => [reverse 1..15]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | {label => 'max_id with ids all cases', req => {ids => [4,14,18,20,24], max_id => 18}, exp_count => 9, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | exp_unacked => [19], exp_acked => [reverse 1..18,20]} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | }else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 8 | {label => "no body", req => undef, exp_count => 10, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | exp_unacked => [], exp_acked => [reverse 1..20]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | {label => "empty", req => {}, exp_count => 10, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | exp_unacked => [], exp_acked => [reverse 1..20]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | {label => 'both null', req => {ids => undef, max_id => undef}, exp_count => 10, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | exp_unacked => [], exp_acked => [reverse 1..20]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | {label => 'empty ids', req => {ids => []}, exp_count => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | exp_unacked => [reverse 11..20], exp_acked => [reverse 1..10]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | {label => 'empty ids with undef max_id', req => {ids => [], max_id => undef}, exp_count => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | exp_unacked => [reverse 11..20], exp_acked => [reverse 1..10]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | {label => 'single ids', req => {ids => 15}, exp_count => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | exp_unacked => [reverse 11..14,16..20], exp_acked => [reverse 1..10,15]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | {label => 'multi ids', req => {ids => [13,14,15]}, exp_count => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | exp_unacked => [reverse 11,12,16..20], exp_acked => [reverse 1..10,13,14,15]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | {label => 'multi ids with unknown id', req => {ids => [19..23]}, exp_count => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | exp_unacked => [reverse 11..18], exp_acked => [reverse 1..10,19,20]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | {label => 'multi ids with acked id', req => {ids => [8..14]}, exp_count => 4, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | exp_unacked => [reverse 15..20], exp_acked => [reverse 1..14]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | {label => 'multi ids (all unknown)', req => {ids => [-1,-4,21,24]}, exp_count => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | exp_unacked => [reverse 11..20], exp_acked => [reverse 1..10]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | {label => 'max_id to unknown id', req => {max_id => 23}, exp_count => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | exp_unacked => [reverse 11..20], exp_acked => [reverse 1..10]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | {label => 'max_id to acked id', req => {max_id => 7}, exp_count => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | exp_unacked => [reverse 11..20], exp_acked => [reverse 1..10]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 36 | ▶ | sub check_contains { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_contains: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 36 | my ($storage, $loop, $unloop, $input, $exp_out, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 36 | local $Test::Builder::Level = $Test::Builder::Level + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 36 | my %args = %$input; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 36 | my $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 36 | ▶ | $args{callback} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 36 | is_deeply \@_, $exp_out, $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 36 | $callbacked++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 36 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 36 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 36 | $storage->contains(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 36 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 36 | is $callbacked, 1, "callbacked once"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 3 | ▶ | sub test_storage_common { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test_storage_common: called CC=24 SCAR=31.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 3 | my ($storage, $loop, $unloop) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 3 | note('-------- test_storage_common'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 3 | ▶ | $loop ||= sub {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
Condition33%1/3
$loop ||= sub {
}
MC/DC0%0/2
$loop ||= sub {
}
$loop
sub {
}
Truth table33%1/3
A ||= B
A= $loopB= sub {
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 3 | ▶ | $unloop ||= sub {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
Condition33%1/3
$unloop ||= sub {
}
MC/DC0%0/2
$unloop ||= sub {
}
$unloop
sub {
}
Truth table33%1/3
A ||= B
A= $unloopB= sub {
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 3 | my $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 3 | isa_ok($storage, 'BusyBird::StatusStorage'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 3 | can_ok($storage, 'get_unacked_counts', map { "${_}_statuses" } qw(ack get put delete)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 3 | note("--- clear the timelines"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 3 | foreach my $tl ('_test_tl1', "_test_tl2") { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 6 | $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | $storage->delete_statuses( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | timeline => $tl, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | ids => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 6 | ▶ | callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 6 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 6 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 6 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 6 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 6 | ok($callbacked, "callbacked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 6 | is_deeply( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | { sync_get_unacked_counts($storage, $loop, $unloop, $tl) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | { total => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | "$tl is empty" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 3 | note("--- put_statuses (insert), single"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 3 | $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | $storage->put_statuses( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | timeline => '_test_tl1', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | mode => 'insert', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | statuses => status(1), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 3 | ▶ | callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 3 | my ($error, $num) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 3 | is($error, undef, 'put_statuses succeed.'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 3 | is($num, 1, 'put 1 status'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 3 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 3 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 3 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 3 | ok($callbacked, "callbacked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 3 | is_deeply( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | { sync_get_unacked_counts($storage, $loop, $unloop, '_test_tl1') }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | { total => 1, 0 => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | '1 unacked status' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 3 | note('--- put_statuses (insert), multiple'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 3 | $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | $storage->put_statuses( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | timeline => '_test_tl1', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | mode => 'insert', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 12 | statuses => [map { status($_) } 2..5], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 3 | ▶ | callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 3 | my ($error, $num) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 3 | is($error, undef, 'put_statuses succeed'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 3 | is($num, 4, 'put 4 statuses'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 3 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 3 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 3 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 3 | ok($callbacked, "callbacked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 3 | is_deeply( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | { sync_get_unacked_counts($storage, $loop, $unloop, '_test_tl1') }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | { total => 5, 0 => 5 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | '5 unacked status' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 3 | note('--- get_statuses: any, all'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 3 | $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | $storage->get_statuses( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | timeline => '_test_tl1', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | count => 'all', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 3 | ▶ | callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 3 | my ($error, $statuses) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 3 | is($error, undef, "get_statuses succeed"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 3 | test_status_id_set($statuses, [1..5], "1..5 statuses"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 3 | foreach my $s (@$statuses) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 7 | ▶ | no autovivification; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 15 | ok(!$s->{busybird}{acked_at}, "status is not acked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 3 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 3 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 3 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 3 | ok($callbacked, "callbacked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 3 | note('--- ack_statuses: all'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 3 | $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | $storage->ack_statuses( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | timeline => '_test_tl1', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 3 | ▶ | callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 3 | my ($error, $num) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 3 | is($error, undef, "ack_statuses succeed"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 3 | is($num, 5, "5 statuses acked."); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 3 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 3 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 3 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 3 | ok($callbacked, "callbacked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 3 | is_deeply( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | { sync_get_unacked_counts($storage, $loop, $unloop, '_test_tl1') }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | { total => 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | "all acked" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | timeline => '_test_tl1', count => 'all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 3 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 3 | is(int(@$statuses), 5, "5 statueses"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 3 | foreach my $s (@$statuses) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 7 | ▶ | no autovivification; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 15 | ok($s->{busybird}{acked_at}, 'acked'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 3 | note('--- delete_statuses (single deletion)'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 3 | $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | $storage->delete_statuses( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | timeline => '_test_tl1', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | ids => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 3 | ▶ | callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 3 | my ($error, $num) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 3 | is($error, undef, "operation succeed."); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 3 | is($num, 1, "1 deletion"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 3 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 3 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 3 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 3 | ok($callbacked, "callbacked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | timeline => '_test_tl1', count => 'all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 3 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 3 | test_status_id_set($statuses, [1,2,4,5], "ID=3 is deleted"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 3 | note('--- delete_statuses (multiple deletion)'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 3 | $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | $storage->delete_statuses( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | timeline => '_test_tl1', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | ids => [1, 4], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 3 | ▶ | callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 3 | my ($error, $num) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 3 | is($error, undef, 'operation succeed'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 3 | is($num, 2, "2 statuses deleted"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 3 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 3 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 3 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 3 | ok($callbacked, "callbacked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | timeline => '_test_tl1', count => 'all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 3 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 3 | test_status_id_set($statuses, [2,5], "ID=1,4 are deleted"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 3 | note('--- delete_statuses (all deletion)'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 3 | $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | $storage->delete_statuses( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | timeline => '_test_tl1', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | ids => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 3 | ▶ | callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 3 | my ($error, $num) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 3 | is($error, undef, 'operation succeed'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 3 | is($num, 2, "2 statuses deleted"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 3 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 3 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 3 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 3 | ok($callbacked, "callbacked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | timeline => '_test_tl1', count => 'all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 3 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 3 | test_status_id_set($statuses, [], "ID=2,5 are deleted. now empty"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 3 | note('--- put_statuses (insert): insert duplicate IDs'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | $storage, $loop, $unloop, timeline => '_test_tl1', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 3 | mode => 'insert', target => [map { status $_ } (1,2,3,2,1,1,4,5,3)], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | exp_change => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | exp_unacked => [1..5], exp_acked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 3 | note('--- ack_statuses: with max_id'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 3 | $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | $storage->ack_statuses( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 3 | ▶ | timeline => '_test_tl1', max_id => 3, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 3 | my ($error, $ack_count) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 3 | is($error, undef, "ack_statuses succeed"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 3 | cmp_ok($ack_count, ">=", 1, "$ack_count (>= 1) acked."); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 3 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 3 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 3 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 3 | ok($callbacked, 'callbacked'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | timeline => '_test_tl1', max_id => 3, count => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 3 | my ($statuses) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 3 | test_status_id_set $statuses, [3], 'get status ID = 3'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 3 | ok(acked($statuses->[0]), 'at least status ID = 3 is acked.'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 3 | note('--- ack_statuses: ack all with max_id => undef'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 3 | $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | $storage->ack_statuses( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 3 | ▶ | timeline => '_test_tl1', max_id => undef, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 3 | my ($error, $ack_count) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 3 | is($error, undef, 'ack_statuses succeed'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 3 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 3 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 3 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 3 | ok($callbacked, "callbacked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | timeline => '_test_tl1', count => 'all', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 3 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 3 | test_status_id_set($statuses, [1..5], "5 statuses"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 3 | foreach my $s (@$statuses) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 15 | ok(acked($s), "Status ID = $s->{id} is acked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 3 | note('--- put (insert): try to insert existent status'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | $storage, $loop, $unloop, timeline => '_test_tl1', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | mode => 'insert', target => status(3), exp_change => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | exp_unacked => [], exp_acked => [1..5] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 3 | note('--- put (update): change to unacked'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | $storage, $loop, $unloop, timeline => '_test_tl1', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 3 | mode => 'update', target => [map {status($_)} (2,4)], exp_change => 2, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | exp_unacked => [2,4], exp_acked => [1,3,5] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 3 | note('--- put (update): change to unacked'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | $storage, $loop, $unloop, timeline => '_test_tl1', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 3 | mode => 'update', target => [map { status($_) } (3,5)], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | exp_change => 2, exp_unacked => [2,3,4,5], exp_acked => [1] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 3 | is_deeply( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | {sync_get_unacked_counts($storage, $loop, $unloop, '_test_tl1')}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | {total => 4, 0 => 4}, '4 unacked statuses' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 3 | note('--- put (update): change level'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | $storage, $loop, $unloop, timeline => '_test_tl1', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | mode => 'update', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 3 | ▶ | target => [map { status($_, ($_ % 2 + 1), $_ == 1 ? nowstring() : undef) } (1..5)], | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | exp_change => 5, exp_unacked => [2,3,4,5], exp_acked => [1] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 3 | is_deeply( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | {sync_get_unacked_counts($storage, $loop, $unloop, '_test_tl1')}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | {total => 4, 1 => 2, 2 => 2}, "4 unacked statuses in 2 levels" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 3 | note('--- put (upsert): acked statuses'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | $storage, $loop, $unloop, timeline => '_test_tl1', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 3 | mode => 'upsert', target => [map { status($_, 7, nowstring()) } (4..7)], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | exp_change => 4, exp_unacked => [2,3], exp_acked => [1,4..7] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 3 | note('--- get and put(update): back to unacked'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | timeline => '_test_tl1', count => 'all', ack_state => 'acked' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 3 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 3 | delete $_->{busybird}{acked_at} foreach @$statuses; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | $storage, $loop, $unloop, timeline => '_test_tl1', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | mode => 'update', target => $statuses, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | exp_change => 5, exp_unacked => [1..7], exp_acked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 3 | is_deeply( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | {sync_get_unacked_counts($storage, $loop, $unloop, '_test_tl1')}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | {total => 7, 1 => 1, 2 => 2, 7 => 4}, "3 levels" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 3 | note('--- put(insert): to another timeline'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | $storage, $loop, $unloop, timeline => '_test_tl2', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 3 | mode => 'insert', target => [map { status($_) } (1..10)], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | exp_change => 10, exp_unacked => [1..10], exp_acked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 3 | is_deeply( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | {sync_get_unacked_counts($storage, $loop, $unloop, '_test_tl2')}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | {total => 10, 0 => 10}, '10 unacked statuses' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | ## change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | ## $storage, $loop, $unloop, timeline => '_test_tl2', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | ## mode => 'ack', target => [1..5], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | ## exp_change => 5, exp_unacked => [6..10], exp_acked => [1..5] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | ## ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | $storage, $loop, $unloop, timeline => '_test_tl2', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 3 | mode => 'update', target => [map {status($_, undef, nowstring())} (1..5)], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | exp_change => 5, exp_unacked => [6..10], exp_acked => [1..5] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 3 | note('--- get: single, any state'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 3 | foreach my $id (1..10) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | timeline => '_test_tl2', count => 1, max_id => $id | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 30 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 30 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 30 | is(int(@$statuses), 1, "get 1 status"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 30 | is($statuses->[0]{id}, $id, "... and its ID is $id"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 30 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 3 | note('--- get: single, specific state'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 3 | foreach my $id (1..10) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 30 | ▶ | my $correct_state = ($id <= 5) ? 'acked' : 'unacked'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 30 | ▶ | my $wrong_state = $correct_state eq 'acked' ? 'unacked' : 'acked'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | timeline => '_test_tl2', count => 1, max_id => $id, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | ack_state => $correct_state, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 30 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 30 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 30 | is(int(@$statuses), 1, "get 1 status"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 30 | is($statuses->[0]{id}, $id, "... and its ID is $id"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 30 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 30 | foreach my $count ('all', 1, 10) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | timeline => '_test_tl2', count => $count, max_id => $id, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | ack_state => $wrong_state | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 90 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 90 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 90 | is(int(@$statuses), 0, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | "no status returned when status specified" . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | " max_id is not the correct ack_state". | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | " even when count = $count"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 90 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 3 | note('--- contains'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 3 | foreach my $case ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | { label => 'single status (in)', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | input => {query => status(3)}, exp => [undef, [status(3)], []]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | { label => 'single status (out)', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | input => {query => status(90)}, exp => [undef, [], [status(90)]]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | { label => 'single id (in)', input => {query => 5}, exp => [undef, [5], []]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | { label => 'single id (out)', input => {query => 8}, exp => [undef, [], [8]]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | { label => 'mixed array', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | input => {query => [ 1, status(10), status(5), 10, 10, 3, 2, status(2), 4, 3, status(0), 8 ]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | exp => [undef, [1, status(5), 3, 2, status(2), 4, 3], [status(10), 10, 10, status(0), 8]]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | { label => 'empty array', input => {query => []}, exp => [undef, [], []]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | { label => 'ID-less status', input => {query => {text => 'hoge'}}, exp => [undef, [], [{text => 'hoge'}]] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | { label => 'mixed ID-less statuses', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | input => {query => [ {text => "foo"}, status(4), 11, {text => 'bar'}, status(9), 3 ]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | exp => [undef, [status(4), 3], [{text => "foo"}, 11, {text => 'bar'}, status(9)]]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 24 | my %args = (%{$case->{input}}, timeline => '_test_tl1'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 24 | check_contains $storage, $loop, $unloop, \%args, $case->{exp}, $case->{label}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 3 | note('--- timeline is independent of each other'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | timeline => "_test_tl1", count => "all" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 3 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 3 | test_status_id_set($statuses, [1..7], "7 statuses in _test_tl1"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | timeline => '_test_tl2', count => "all", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 3 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 3 | test_status_id_set($statuses, [1..10], "10 statuses in _test_tl2"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 3 | check_contains($storage, $loop, $unloop, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | {timeline => '_test_tl2', query => [5, 7, 9, 11]}, [undef, [5,7,9], [11]], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 'contains() for _test_tl2 timeline'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 3 | note('--- access to non-existent statuses'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 3 | foreach my $test_set ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 15 | {mode => 'update', target => [map { status($_) } (11..15) ]}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | {mode => 'delete', target => [11..15]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 6 | ▶ | my $label = "mode $test_set->{mode} " . ($test_set->{label} || ""); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$test_set{'label'} || ''
MC/DC0%0/1
$$test_set{'label'} || ''
$$test_set{'label'}
Truth table50%1/2
A
A= $$test_set{'label'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 6 | my %target_args = %$test_set; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 6 | delete @target_args{"mode", "label"}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | $storage, $loop, $unloop, timeline => '_test_tl2', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 6 | mode => $test_set->{mode}, label => $label, %target_args, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | exp_change => 0, exp_unacked => [6..10], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | exp_acked => [1..5] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | timeline => '_test_tl2', count => 'all', max_id => 15, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 3 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 3 | is(int(@$statuses), 0, "get max_id=15 returns empty"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 3 | note('--- access to non-existent timeline'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 3 | foreach my $mode (qw(update delete ack)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 9 | my $timeline = '_this_timeline_ probably does not exist'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 9 | ▶ | my $target = $mode eq 'update' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | ? status(1) : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 9 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | $storage, $loop, $unloop, timeline => $timeline, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | mode => $mode, target => $target, lable => "mode $mode", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | exp_change => 0, exp_unacked => [], exp_acked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 3 | check_contains($storage, $loop, $unloop, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | {timeline => "_non_existent timeline", query => [0..20]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | [undef, [], [0..20]], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 'contains() for non-existent timeline returns all queries as not_contained'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 3 | note('--- changes done to obtained statuses do not affect storage.'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | timeline => '_test_tl2', count => 'all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 3 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 3 | is(int(@$statuses), 10, "10 statuses"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 3 | $_->{id} = 100 foreach @$statuses; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | timeline => '_test_tl2', count => 'all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 3 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 3 | test_status_id_set($statuses, [1..10], "ID set in storage is not changed."); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 3 | note('--- changes done to inserted/updated statuses do not affect storage.'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 3 | my @upserted = map { status $_ } 1..20; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | $storage, $loop, $unloop, timeline => '_test_tl2', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | mode => 'upsert', target => \@upserted, exp_change => 20, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | exp_acked => [], exp_unacked => [1..20] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 3 | $_->{id} = 100 foreach @upserted; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | timeline => '_test_tl2', count => 'all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 3 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 3 | test_status_id_set($statuses, [1..20], 'ID set in storage is not changed'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 3 | note('--- -- test acks with max_id (unordered)'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 3 | $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 3 | ▶ | $storage->delete_statuses(timeline => '_test_acks', ids => undef, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 3 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 3 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 3 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 3 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 3 | ok($callbacked, 'callbacked'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | $storage, $loop, $unloop, timeline => '_test_acks', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 3 | mode => 'insert', target => [map {status($_)} 1..30], exp_change => 30, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | exp_acked => [], exp_unacked => [1..30] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 3 | note('--- ack: ids and max_id (max_id < ids)'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 3 | $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 3 | ▶ | $storage->ack_statuses(timeline => '_test_acks', ids => [25..28], max_id => 4, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 3 | my ($error, $count) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 3 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 3 | is($error, undef, "ack_statuses succeed"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 3 | cmp_ok($count, ">=", 5, 'at least 5 statuses acked.'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 3 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 3 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 3 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 3 | ok($callbacked, "callbacked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | $storage, $loop, $unloop, timeline => '_test_acks', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | mode => 'delete', target => undef, exp_change => 30, exp_acked => [], exp_unacked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | $storage, $loop, $unloop, timeline => '_test_acks', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 3 | mode => 'insert', target => [map {status($_)} 31..40], exp_change => 10, exp_acked => [], exp_unacked => [31..40] | |||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 3 | note('--- ack: ids and max_id (max_id > ids)'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 3 | $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 3 | ▶ | $storage->ack_statuses(timeline => '_test_acks', ids => 32, max_id => 39, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 3 | my ($error, $count) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 3 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 3 | is($error, undef, 'ack_statuses succeed'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 3 | cmp_ok($count, ">=", 2, "at least 2 statuses acked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 3 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 3 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 3 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 3 | ok($callbacked, "callbacked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | $storage, $loop, $unloop, timeline => '_test_acks', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | mode => 'delete', target => undef, exp_change => 10, exp_acked => [], exp_unacked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 3 | note('--- -- acks with various argument cases (unordered)'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 3 | foreach my $case (test_cases_for_ack(is_ordered => 0)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 36 | my $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 36 | ▶ | next if not defined $case->{req}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 33 | note("--- case: $case->{label}"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 33 | ▶ | $storage->delete_statuses(timeline => '_test_acks', ids => undef, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 33 | my ($error, $count) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 33 | is($error, undef, "delete succeed"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 33 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 33 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 33 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 33 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 33 | ok($callbacked, 'callbacked'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 33 | my $already_acked_at = nowstring(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | $storage, $loop, $unloop, timeline => '_test_acks', mode => 'insert', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 33 | target => [(map {status($_, 0, $already_acked_at)} 1..10), (map {status($_)} 11..20)], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | exp_change => 20, exp_acked => [1..10], exp_unacked => [11..20] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 33 | my %target_args = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 33 | ▶ | $target_args{target_ids} = $case->{req}{ids} if exists $case->{req}{ids}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 33 | ▶ | $target_args{target_max_id} = $case->{req}{max_id} if exists $case->{req}{max_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | $storage, $loop, $unloop, timeline => '_test_acks', mode => 'ack', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | %target_args, exp_change => $case->{exp_count}, exp_acked => $case->{exp_acked}, exp_unacked => $case->{exp_unacked} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 33 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 3 | note('--- -- -- Unicode timeline name and Unicode status ID'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 3 | foreach my $timeline_name ("_test_ascii", '_test_ゆにこーど') { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 6 | note(encode_utf8("--- -- timeline: $timeline_name")); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 6 | ▶ | $storage->delete_statuses(timeline => $timeline_name, ids => undef, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 6 | my $e = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 6 | is($e, undef, "initial delete"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 6 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 6 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 6 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 6 | my @statuses = map { status($_) } 0..1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 6 | $statuses[1]{id} = 'いち'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 6 | $statuses[0]{text} = 'テキスト ゼロ'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 6 | $statuses[1]{text} = 'テキスト いち'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 6 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | $storage, $loop, $unloop, timeline => $timeline_name, mode => 'insert', target => \@statuses, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | exp_change => 2, exp_acked => [], exp_unacked => [qw(0 いち)] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 6 | check_contains($storage, $loop, $unloop, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | {timeline => $timeline_name, query => [$statuses[1], 'に', 'いち', 0]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | [undef, [$statuses[1], 'いち', 0], ['に']], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | encode_utf8("contains() works fine with Unicode timeline $timeline_name and Unicode status IDs")); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 6 | ▶ | $storage->get_unacked_counts(timeline => $timeline_name, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 6 | my ($e, $unacked_counts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 6 | is($e, undef, "get unacked counts succeed"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 6 | is_deeply($unacked_counts, {total => 2, 0 => 2}, "unacked counts OK"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 6 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 6 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 6 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | $storage, $loop, $unloop, timeline => $timeline_name, mode => 'ack', target_ids => $statuses[1]{id}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 6 | exp_change => 1, exp_acked => ["いち"], exp_unacked => [0] | |||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 6 | foreach my $status (@statuses) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | my $got_statuses = sync_get( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | timeline => $timeline_name, count => 1, max_id => $status->{id} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 12 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 12 | test_status_id_list($got_statuses, [$status->{id}], encode_utf8("status ID $status->{id} OK")); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 12 | is($got_statuses->[0]{text}, $status->{text}, encode_utf8("status text '$status->{text}' OK")); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 12 | ▶ | if($got_statuses->[0]{id} eq "0") { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 6 | ok(!$got_statuses->[0]{busybird}{acked_at}, "status 0 is not acked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | }else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 6 | ok($got_statuses->[0]{busybird}{acked_at}, "status 1 is acked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 6 | $statuses[1]{busybird}{level} = 5; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 6 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | $storage, $loop, $unloop, timeline => $timeline_name, mode => "update", target => $statuses[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | exp_change => 1, exp_acked => [], exp_unacked => [0, "いち"] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 6 | ▶ | $storage->get_unacked_counts(timeline => $timeline_name, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 6 | my ($e, $unacked_counts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 6 | is($e, undef, "get unacked counts succeed"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 6 | is_deeply($unacked_counts, {total => 2, 0 => 1, 5 => 1}, "unacked counts OK"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 6 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 6 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 6 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 6 | $storage, $loop, $unloop, timeline => $timeline_name, mode => "delete", target => [map {$_->{id}} @statuses], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | exp_change => 2, exp_acked => [], exp_unacked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 3 | note('--- clean up'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 3 | foreach my $tl ('_test_tl1', '_test_tl2') { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 6 | $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 6 | ▶ | $storage->delete_statuses(timeline => $tl, ids => undef, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 6 | my $error= shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 6 | is($error, undef, "operation succeed"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 6 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 6 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 6 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 6 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 6 | ok($callbacked, "callbacked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 3 | ▶ | sub test_storage_ordered { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test_storage_ordered: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 3 | my ($storage, $loop, $unloop) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 3 | ▶ | $loop ||= sub {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
Condition33%1/3
$loop ||= sub {
}
MC/DC0%0/2
$loop ||= sub {
}
$loop
sub {
}
Truth table33%1/3
A ||= B
A= $loopB= sub {
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 3 | ▶ | $unloop ||= sub {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
Condition33%1/3
$unloop ||= sub {
}
MC/DC0%0/2
$unloop ||= sub {
}
$unloop
sub {
}
Truth table33%1/3
A ||= B
A= $unloopB= sub {
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 3 | note('-------- test_storage_ordered'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 3 | note('--- clear timeline'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 3 | my $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 3 | foreach my $tl (qw(_test_tl3 _test_tl4 _test_tl5)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 9 | $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 9 | ▶ | $storage->delete_statuses(timeline => $tl, ids => undef, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 9 | my $error = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 9 | is($error, undef, "operation succeed"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 9 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 9 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 9 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 9 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 9 | ok($callbacked, "callbacked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 3 | note('--- acked_at and created_at are preserved'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 3 | foreach my $case ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | {label => "both unset", created_at => undef, acked_at => undef}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | {label => "only created_at set", created_at => 'Mon Jul 01 22:11:41 +0900 2013', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | acked_at => undef}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | {label => "only acked_at set", created_at => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | acked_at => "Wed Apr 17 04:23:29 -0500 2013"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | {label => 'both set', created_at => 'Fri Oct 12 00:36:44 +0000 2012', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | acked_at => 'Thu Oct 25 13:10:00 +0200 2012'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 12 | note("--- -- case: $case->{label}"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 12 | $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 12 | my $status = status(1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 12 | $status->{created_at} = $case->{created_at}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 12 | $status->{busybird}{acked_at} = $case->{acked_at}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | $storage->put_statuses( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | timeline => "_test_tl3", mode => 'insert', statuses => $status, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 12 | ▶ | callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 12 | my ($error, $count) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 12 | is($error, undef, "put succeed"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 12 | is($count, 1, "1 inserted"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 12 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 12 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 12 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 12 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 12 | ok($callbacked, "callbacked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 12 | ▶ | on_statuses $storage, $loop, $unloop, {timeline => '_test_tl3', count => 'all'}, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 12 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 12 | is(scalar(@$statuses), 1, "1 status obtained"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 12 | is($statuses->[0]{created_at}, $case->{created_at}, "created_at is preserved"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 12 | is($statuses->[0]{busybird}{acked_at}, $case->{acked_at}, "acked_at is preserved"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 12 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | $storage, $loop, $unloop, timeline => '_test_tl3', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | mode => 'delete', target => undef, exp_change => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | exp_unacked => [], exp_acked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 3 | note('--- populate timeline'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | $storage, $loop, $unloop, timeline => '_test_tl3', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 3 | mode => 'insert', target => [map {status $_} (1..30)], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | label => 'first insert', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | exp_change => 30, exp_unacked => [1..30], exp_acked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | $storage, $loop, $unloop, timeline => '_test_tl3', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | mode => 'ack', target => undef, label => 'ack all', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | exp_change => 30, exp_unacked => [], exp_acked => [1..30] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | $storage, $loop, $unloop, timeline => '_test_tl3', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 3 | mode => 'insert', target => [map {status $_} (31..60)], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | label => "another insert", exp_change => 30, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | exp_unacked => [31..60], exp_acked => [1..30] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 3 | my %base = (timeline => '_test_tl3'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | $storage, $loop, $unloop, {%base, count => 'all'}, [reverse 1..60], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 'get: no max_id, any state, all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | $storage, $loop, $unloop, {%base, count => 20}, [reverse 41..60], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 'get: no max_id, any state, partial' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | $storage, $loop, $unloop, {%base, count => 40}, [reverse 21..60], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 'get: no max_id, any state, both states' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | $storage, $loop, $unloop, {%base, count => 120}, [reverse 1..60], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 'get: no max_id, any state, count larger than the size' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | {%base, ack_state => 'unacked', count => 'all'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | [reverse 31..60], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 'get: no max_id unacked, all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | {%base, ack_state => 'unacked', count => 15}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | [reverse 46..60 ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 'get: no max_id, unacked, partial' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | {%base, ack_state => 'unacked', count => 50}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | [reverse 31..60], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 'get: no max_id, unacked, larger than the unacked size' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | {%base, ack_state => 'acked', count => 'all'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | [reverse 1..30], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 'get: no max_id, acked, all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | {%base, ack_state => 'acked', count => 25}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | [reverse 6..30], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 'get: no max_id, acked, partial' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | {%base, ack_state => 'acked', count => 70}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | [reverse 1..30], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 'get: no max_id, acked, larger than the acked size' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | {%base, ack_state => 'any', max_id => 40, count => 'all'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | [reverse 1..40], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 'get: max_id in unacked, any state, all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | {%base, ack_state => 'any', max_id => 20, count => 'all'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | [reverse 1..20], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 'get: max_id in acked, any state, all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | {%base, ack_state => 'any', max_id => 70, count => 'all'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | [], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 'get: non-existent max_id, any state, all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | {%base, ack_state => 'any', max_id => 50, count => 10}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | [reverse 41..50], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 'get: max_id in unacked, any state, count inside unacked zone' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | {%base, ack_state => 'any', max_id => 50, count => 40}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | [reverse 11..50], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 'get: max_id in unacked, any state, count to acked zone' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | {%base, ack_state => 'any', max_id => 30, count => 20}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | [reverse 11..30], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 'get: max_id in acked, any state, partial' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | {%base, ack_state => 'any', max_id => 10, count => 40}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | [reverse 1..10], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 'get: max_id in acked, any state, count larger than the acked size' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | {%base, ack_state => 'unacked', max_id => 45, count => 5}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | [reverse 41..45], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 'get: max_id in unacked, unacked state, count in unacked' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | {%base, ack_state => 'unacked', max_id => 45, count => 25}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | [reverse 31..45], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 'get: max_id in unacked, unacked state, count larger than the unacked size' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | {%base, ack_state => 'unacked', max_id => 20, count => 5}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | [], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 'get: max_id in acked, unacked state' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | {%base, ack_state => 'acked', max_id => 50, count => 10}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | [], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 'get: max_id in unacked, acked state, count in unacked' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | {%base, ack_state => 'acked', max_id => 45, count => 30}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | [], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 'get: max_id in unacked, acked state, count larger than the unacked size' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | {%base, ack_state => 'acked', max_id => 20, count => 10}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | [reverse 11..20], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 'get: max_id in acked, acked state, count in acked' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | {%base, ack_state => 'acked', max_id => 10, count => 30}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | [reverse 1..10], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 'get: max_id in acked, acked state, count larger than acked size' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 3 | note('--- more acked statuses'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 3 | my $now = DateTime->now(time_zone => 'UTC'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 3 | my $yesterday = $now - DateTime::Duration->new(days => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 3 | my $tomorrow = $now + DateTime::Duration->new(days => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | my @more_statuses = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 30 | (map { status $_, 0, $datetime_formatter->format_datetime($tomorrow) } 61..70), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 3 | (map { status $_, 0, $datetime_formatter->format_datetime($yesterday) } 71..80) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | $storage, $loop, $unloop, timeline => '_test_tl3', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | mode => 'insert', target => \@more_statuses, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | exp_change => 20, exp_unacked => [31..60], exp_acked => [1..30, 61..80] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | get_and_check_list( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 3 | $storage, $loop, $unloop, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | {%base, ack_state => 'any', count => 'all'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | [reverse(71..80, 1..30, 61..70, 31..60)], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 'get: mixed acked_at, no max_id, any state, all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 3 | note('--- move from acked to unacked'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | timeline => '_test_tl3', acked_state => 'acked', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | max_id => 30, count => 10 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 3 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 3 | delete $_->{busybird}{acked_at} foreach @$statuses; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | $storage, $loop, $unloop, timeline => '_test_tl3', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | mode => 'update', target => $statuses, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | exp_change => 10, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | exp_unacked => [21..60], exp_acked => [1..20, 61..80] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | {%base, ack_state => 'any', count => 'all'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | [reverse(71..80, 1..20, 61..70, 21..60)], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 'get:mixed acked_at, no max_id, any state, all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | {%base, ack_state => 'any', max_id => 30, count => 30}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | [reverse(11..20, 61..70, 21..30)], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 'get:mixed acked_at, max_id in unacked, any state, count larger than unacked size' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | {%base, ack_state => 'any', max_id => 15, count => 20}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | [reverse(76..80, 1..15)], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 'get:mixed acked_at, max_id in acked, any state, count in acked' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | {%base, ack_state => 'unacked', max_id => 50, count => 50}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | [reverse(21..50)], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 'get:mixed acked_at, max_id in unacked, unacked state, count larger than unacked size' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | {%base, ack_state => 'acked', max_id => 65, count => 30}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | [reverse(76..80, 1..20, 61..65)], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 'get:mixed acked_at, max_id in acked, acked state, count in acked area' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | {%base, ack_state => 'unacked', max_id => 20, count => 30}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | [], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 'get:mixed acked_at, max_id in acked, unacked state' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | {%base, ack_state => 'acked', max_id => 40, count => 30}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | [], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 'get:mixed acked_at, max_id in unacked, acked state' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 3 | note('--- messing with created_at'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | timeline => '_test_tl3', count => 'all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 3 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 3 | is(int(@$statuses), 80, "80 statuses"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 3 | foreach my $s (@$statuses) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | $s->{created_at} = $datetime_formatter->format_datetime( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | $datetime_formatter->parse_datetime($s->{created_at}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | + DateTime::Duration->new(days => 100 - $s->{id}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 240 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 3 | $storage, $loop, $unloop, timeline => '_test_tl3', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | mode => 'update', target => $statuses, exp_change => 80, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | exp_unacked => [21..60], exp_acked => [1..20, 61..80] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | $storage, $loop, $unloop, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | {%base, ack_state => 'any', count => 'all'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | [21..60, 61..70, 1..20, 71..80], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 'sorted by descending order of created_at within acked_at group' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 3 | note('--- -- ack test'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 3 | note('--- change acked_at for testing'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | %base, count => 'all', ack_state => 'acked' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 3 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 3 | foreach my $s (@$statuses) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | $s->{busybird}{acked_at} = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 120 | add_datetime_days($s->{busybird}{acked_at}, +2); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 3 | $storage, $loop, $unloop, %base, mode => 'update', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | target => $statuses, exp_change => 40, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | exp_unacked => [21..60], exp_acked => [61..70, 1..20, 71..80] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | $storage, $loop, $unloop, %base, mode => 'ack', target => 51, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | exp_change => 10, exp_unacked => [21..50], exp_acked => [61..70, 1..20, 71..80, 51..60] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | $storage, $loop, $unloop, {%base, ack_state => 'any', count => 'all'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | [21..50, 61..70, 1..20, 71..80, 51..60], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | '10 acked statuses are at the bottom, because other acked statuses have acked_at of future.' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 3 | note('--- populate another timeline'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 3 | my %base4 = (timeline => '_test_tl4'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 3 | $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 3 | ▶ | $storage->delete_statuses(%base4, ids => undef, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 3 | my $error = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | 3 | is($error, undef, "delete succeed"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 3 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 3 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | 3 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 3 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | 3 | ok($callbacked, "callbacked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | $storage, $loop, $unloop, %base4, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 3 | mode => 'insert', target => [map {status($_)} (31..40)], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | exp_change => 10, exp_unacked => [31..40], exp_acked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | $storage, $loop, $unloop, {%base4, count => 'all'}, [reverse 31..40], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | '10 unacked' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | $storage, $loop, $unloop, %base4, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | mode => 'ack', target => 35, exp_change => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | exp_unacked => [36..40], exp_acked => [31..35] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | $storage, $loop, $unloop, {%base4, count => 'all', ack_state => 'acked'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | [reverse 31..35], '5 acked' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | $storage, $loop, $unloop, %base4, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | 3 | mode => 'insert', target => [map {status($_)} (26..30, 41..45)], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | exp_change => 10, exp_unacked => [26..30, 36..45], exp_acked => [31..35] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | $storage, $loop, $unloop, {%base4, count => 'all', ack_state => 'unacked'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | [reverse 26..30, 36..45], '15 unacked statuses' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | 3 | note('--- For testing, set acked_at sufficiently old.'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | %base4, count => 'all', ack_state => 'acked' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 3 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 3 | foreach my $s (@$statuses) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 15 | $s->{busybird}{acked_at} = add_datetime_days($s->{busybird}{acked_at}, -1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | 3 | $storage, $loop, $unloop, %base4, mode => 'update', target => $statuses, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | exp_change => 5, exp_unacked => [26..30, 36..45], exp_acked => [31..35] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | $storage, $loop, $unloop, %base4, mode => 'ack', target => 40, exp_change => 10, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | exp_unacked => [41..45], exp_acked => [36..40, 26..30, 31..35] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | 3 | get_and_check_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | $storage, $loop, $unloop, {%base4, count => 'all', ack_state => 'acked'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | [reverse(36..40), reverse(26..30), reverse(31..35)] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | $storage, $loop, $unloop, %base4, mode => 'ack', exp_change => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | exp_unacked => [], exp_acked => [26..45] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | 3 | note('--- same timestamp: order is free, but must be consistent.'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | 3 | my %base5 = (timeline => '_test_tl5'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 3 | my @in_statuses = map {status($_)} (1..10); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | 3 | my $created_at = nowstring; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 3 | $_->{created_at} = $created_at foreach @in_statuses; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | $storage, $loop, $unloop, %base5, mode => 'insert', target => [@in_statuses[0..4]], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | label => 'insert first five', exp_change => 5, exp_unacked => [1..5], exp_acked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | $storage, $loop, $unloop, %base5, mode => 'ack', target => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | label => 'ack first five', exp_change => 5, exp_unacked => [], exp_acked => [1..5] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | $storage, $loop, $unloop, %base5, mode => 'insert', target => [@in_statuses[5..9]], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | label => 'insert next five', exp_change => 5, exp_unacked => [6..10], exp_acked => [1..5] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 3 | my $whole_timeline = sync_get($storage, $loop, $unloop, %base5, count => 'all'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | 3 | foreach my $start_index (0..9) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | 30 | my $max_id = $whole_timeline->[$start_index]{id}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | get_and_check_list( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | $storage, $loop, $unloop, {%base5, count => 'all', max_id => $max_id}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 30 | [ map {$_->{id}} @{$whole_timeline}[$start_index .. 9] ], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | "start_index = $start_index, max_id = $max_id: order is the same as the whole_timeline" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 3 | note('--- -- acks with various argument cases (ordered)'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | 3 | foreach my $case (test_cases_for_ack(is_ordered => 1)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | 15 | my $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | 15 | ▶ | next if not defined $case->{req}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | 15 | note("--- case: $case->{label}"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | 15 | ▶ | $storage->delete_statuses(timeline => '_test_acks', ids => undef, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 15 | my ($error, $count) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 15 | is($error, undef, "delete succeed"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 15 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | 15 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 15 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 15 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | 15 | ok($callbacked, 'callbacked'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | 15 | my $already_acked_at = add_datetime_days(nowstring(), -1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | $storage, $loop, $unloop, timeline => '_test_acks', mode => 'insert', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 15 | target => [(map {status($_, 0, $already_acked_at)} 1..10), (map {status($_)} 11..20)], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | exp_change => 20, exp_acked => [1..10], exp_unacked => [11..20] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | 15 | my %target_args = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | 15 | ▶ | $storage->ack_statuses(timeline => '_test_acks', %{$case->{req}}, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | 15 | my ($error, $count) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | 15 | is($error, undef, "ack succeed"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | 15 | is($count, $case->{exp_count}, "count is $case->{exp_count}"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | 15 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | 15 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | 15 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | 15 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | 15 | ok($callbacked, "callbacked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | get_and_check_list( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | $storage, $loop, $unloop, {timeline => '_test_acks', count => 'all', ack_state => 'acked'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 15 | $case->{exp_acked}, "ordered acked statuses OK" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | get_and_check_list( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | $storage, $loop, $unloop, {timeline => '_test_acks', count => 'all', ack_state => 'unacked'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | 15 | $case->{exp_unacked}, "ordered unacked statuses OK" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | 3 | ▶ | sub test_storage_truncation { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test_storage_truncation: called CC=9 SCAR=22.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | 3 | my ($storage, $options, $loop, $unloop) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | 3 | note("-------- test_storage_truncation"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | 3 | ▶ | if(!defined($options) || ref($options) ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $options or ref $options ne "HASH"
MC/DC0%0/2
not defined $options or ref $options ne "HASH"
not defined $options
ref $options ne "HASH"
Truth table33%1/3
not(A) or B
A= not defined $optionsB= ref $options ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | 0 | croak "options must be a hash-ref"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | 3 | ▶ | croak "soft_max option is mandatory" if not defined $options->{soft_max}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 3 | my $soft_max = int($options->{soft_max}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | 3 | ▶ | croak "soft_max must be bigger than 0" if !($soft_max > 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | 3 | ▶ | my $hard_max = defined($options->{hard_max}) ? $options->{hard_max} : $soft_max; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 3 | $hard_max = int($hard_max); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | 3 | ▶ | croak "hard_max must be >= soft_max" if !($hard_max >= $soft_max); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | 3 | note("--- soft_max = $soft_max, hard_max = $hard_max"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | 3 | ▶ | $loop ||= sub {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
Condition33%1/3
$loop ||= sub {
}
MC/DC0%0/2
$loop ||= sub {
}
$loop
sub {
}
Truth table33%1/3
A ||= B
A= $loopB= sub {
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | 3 | ▶ | $unloop ||= sub {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
Condition33%1/3
$unloop ||= sub {
}
MC/DC0%0/2
$unloop ||= sub {
}
$unloop
sub {
}
Truth table33%1/3
A ||= B
A= $unloopB= sub {
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | 3 | note('--- clear the timeline'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | 3 | my $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 3 | my %base = (timeline => '_test_tl4'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 3 | ▶ | $storage->delete_statuses(%base, ids => undef, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 3 | my $error = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 3 | is($error, undef, "delete succeed"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | 3 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | 3 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | 3 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | 3 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | 3 | ok($callbacked, 'callbacked'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | %base, count => 'all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | 3 | my ($statuses) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | 3 | is(int(@$statuses), 0, 'no statuses'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | 3 | note('--- populate to the max'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | $storage, $loop, $unloop, %base, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | 3 | mode => 'insert', target => [map {status($_)} (1..$hard_max)], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | exp_change => $hard_max, exp_unacked => [1..$hard_max], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | exp_acked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | 3 | note('--- insert another one: truncation occurs'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | $storage, $loop, $unloop, %base, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | mode => 'insert', target => status($hard_max+1), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | exp_change => 1, exp_unacked => [($hard_max+1 - ($soft_max-1))..($hard_max+1)], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | exp_acked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | 3 | note('--- insert multiple statuses: truncation occurs'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | $storage, $loop, $unloop, %base, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 3 | mode => 'insert', target => [map { status($_) } ($hard_max+2) .. ($hard_max*2 - $soft_max + 11)], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | exp_change => ($hard_max - $soft_max + 10), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | exp_unacked => [($hard_max*2 - $soft_max*2 + 12) .. ($hard_max*2 - $soft_max + 11)], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | exp_acked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | 3 | note('--- clear and populate to the max'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | $storage, $loop, $unloop, %base, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | mode => 'delete', target => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | exp_change => $soft_max, exp_unacked => [], exp_acked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | $storage, $loop, $unloop, %base, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | 3 | mode => 'insert', target => [map {status($_)} 1..$hard_max], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | exp_change => $hard_max, exp_unacked => [1..$hard_max], exp_acked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | 3 | note('--- ack the top status'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | %base, count => 1, max_id => $hard_max | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | 3 | my ($statuses) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | 3 | $statuses->[0]{busybird}{acked_at} = nowstring(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | $storage, $loop, $unloop, %base, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | mode => 'update', target => $statuses, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | exp_change => 1, exp_unacked => [1..($hard_max-1)], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | exp_acked => [$hard_max] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | 3 | note('--- inserting another one removes the acked status'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | 3 | change_and_check( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | $storage, $loop, $unloop, %base, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | mode => 'insert', target => status($hard_max+1), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | exp_change => 1, exp_unacked => [($hard_max - $soft_max + 1)..($hard_max - 1), ($hard_max + 1)], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | exp_acked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | 3 | note('--- populate timeline to the max'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | $storage, $loop, $unloop, %base, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 3 | mode => 'insert', target => [map {status($_)} ($hard_max+2) .. ($hard_max+2 + $hard_max - $soft_max - 1)], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | exp_change => $hard_max - $soft_max, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | exp_unacked => [($hard_max - $soft_max + 1)..($hard_max - 1), ($hard_max + 1)..($hard_max*2+2 - $soft_max-1)], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | exp_acked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | 3 | note('--- clear another timeline'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | 3 | ▶ | $storage->delete_statuses(timeline => '_test_tl4_2', ids => undef, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | 3 | my $error = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | 3 | is($error, undef, "delete succeed"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | 3 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | 3 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | 3 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | 3 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | 3 | ok($callbacked, "callbacked"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | 3 | note('--- populate another timeline to the max'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | change_and_check( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | $storage, $loop, $unloop, timeline => '_test_tl4_2', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | 3 | mode => 'insert', target => [map {status($_)} 1..$hard_max], | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | exp_change => $hard_max, exp_unacked => [1..$hard_max], exp_acked => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | 3 | note('--- statuses in the first timeline is maintained.'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | on_statuses $storage, $loop, $unloop, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | %base, count => 'all' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | 3 | ▶ | }, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | 3 | my $statuses = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | 3 | test_status_id_list( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | $statuses, [reverse( ($hard_max - $soft_max + 1)..($hard_max - 1), ($hard_max + 1)..($hard_max*2+2 - $soft_max-1) )], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | "statuses in the first timeline are intact" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | 3 | ▶ | sub test_storage_missing_arguments { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test_storage_missing_arguments: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | 3 | my ($storage, $loop, $unloop) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | 3 | note("-------- test_storage_missing_arguments"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | 3 | ▶ | dies_ok { $storage->ack_statuses() } 'ack: timeline is missing'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | 3 | ▶ | dies_ok { $storage->get_statuses(callback => sub {}) } 'get: timeline is missing'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | 3 | ▶ | dies_ok { $storage->get_statuses(timeline => 'tl') } 'get: callback is missing'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | 3 | ▶ | dies_ok { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | 3 | $storage->put_statuses(mode => 'insert', statuses => []); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | 3 | } 'put: timeline is missing'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | 3 | ▶ | dies_ok { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | 3 | $storage->put_statuses(timeline => 'tl', mode => 'insert'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | 3 | } 'put: statuses is missing'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | 3 | ▶ | dies_ok { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | 3 | $storage->put_statuses(timeline => 'tl', statuses => []); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | 3 | } 'put: mode is missing'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | 3 | ▶ | dies_ok { $storage->delete_statuses(ids => undef) } 'delete: timeline is missing'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | 3 | ▶ | dies_ok { $storage->delete_statuses(timeline => 'tl') } 'delete: ids is missing'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | 3 | ▶ | dies_ok { $storage->get_unacked_counts(callback => sub {}) } 'get_unacked: timeline is missing'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | 3 | ▶ | dies_ok { $storage->get_unacked_counts(timeline => 'tl') } 'get_unacked: callback is missing'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | 3 | ▶ | dies_ok { $storage->contains(query => 10, callback => sub {}) } 'contains: timeline is missing'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | 3 | ▶ | dies_ok { $storage->contains(timeline => 'tl', callback => sub {}) } 'contains: query is missing'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | 3 | ▶ | dies_ok { $storage->contains(timeline => 'tl', query => 10) } 'contains: callback is missing'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | 3 | ▶ | sub test_storage_requires_status_ids { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test_storage_requires_status_ids: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | 3 | my ($storage, $loop, $unloop) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | 3 | note("-------- test_storage_requires_status_ids"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | 3 | ▶ | $loop ||= sub {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
Condition33%1/3
$loop ||= sub {
}
MC/DC0%0/2
$loop ||= sub {
}
$loop
sub {
}
Truth table33%1/3
A ||= B
A= $loopB= sub {
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | 3 | ▶ | $unloop ||= sub {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
Condition33%1/3
$unloop ||= sub {
}
MC/DC0%0/2
$unloop ||= sub {
}
$unloop
sub {
}
Truth table33%1/3
A ||= B
A= $unloopB= sub {
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | 3 | my %cases = ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | no_id => status(1), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | undef_id => status(2), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | 3 | my $ok_status = status(3); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | 3 | delete $cases{no_id}{id}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | 3 | $cases{undef_id}{id} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | 0 | ▶ | my %base = (timeline => '_test_tl_requires_status_ids', callback => sub { fail("callbacked") }); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | 3 | my $callbacked = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | 3 | ▶ | $storage->delete_statuses(%base, ids => undef, callback => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | 3 | my $error = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | 3 | is($error, undef, 'delete succeed'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | 3 | $callbacked = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | 3 | $unloop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | 3 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | 3 | $loop->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | 3 | ok($callbacked, 'callbacked'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | 3 | foreach my $case (keys %cases) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | 6 | my $s = $cases{$case}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | 6 | ▶ | dies_ok { $storage->put_statuses(%base, mode => 'insert', statuses => $s) } "case: $case, insert, single: dies OK"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | 6 | ▶ | dies_ok { $storage->put_statuses(%base, mode => 'update', statuses => $s) } "case: $case, update, single: dies OK"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | 6 | ▶ | dies_ok { $storage->put_statuses(%base, mode => 'upsert', statuses => $s) } "case: $case, upsert, single: dies OK"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | 6 | ▶ | dies_ok { $storage->put_statuses(%base, mode => 'insert', statuses => [$ok_status, $s]) } "case: $case, insert, array: dies OK"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | 6 | ▶ | dies_ok { $storage->put_statuses(%base, mode => 'update', statuses => [$ok_status, $s]) } "case: $case, update, array: dies OK"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | 6 | ▶ | dies_ok { $storage->put_statuses(%base, mode => 'upsert', statuses => [$ok_status, $s]) } "case: $case, upsert, array: dies OK"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | 6 | my $statuses = sync_get($storage, $loop, $unloop, timeline => $base{timeline}, count => 'all'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | 6 | is(int(@$statuses), 0, 'storage is empty'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | 3 | ▶ | sub test_storage_undef_in_array { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test_storage_undef_in_array: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | 3 | my ($storage, $loop, $unloop) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | 3 | note("-------- test_storage_undef_in_array"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | 0 | ▶ | my %base = (timeline => '_timeline_undef_in_array', callback => sub { fail("callbacked") }); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | 3 | ▶ | dies_ok { $storage->ack_statuses(%base, ids => [1, 10, undef]) } "ack dies OK"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | 3 | foreach my $mode (qw(insert update upsert)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | 9 | ▶ | dies_ok { $storage->put_statuses(%base, mode => $mode, statuses => [undef, {id => 10}]) } "$mode dies OK"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | 3 | ▶ | dies_ok { $storage->delete_statuses(%base, ids => [undef, undef, 9]) } "delete dies OK"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | 3 | ▶ | dies_ok { $storage->contains(%base, query => [undef, 10, {id => 8}]) } "contains dies OK"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||