| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Mock::Mango::Cursor; |
|
2
|
|
|
|
|
|
|
|
|
3
|
20
|
|
|
20
|
|
1036
|
use v5.10; |
|
|
20
|
|
|
|
|
61
|
|
|
|
20
|
|
|
|
|
831
|
|
|
4
|
20
|
|
|
20
|
|
101
|
use strict; |
|
|
20
|
|
|
|
|
32
|
|
|
|
20
|
|
|
|
|
548
|
|
|
5
|
20
|
|
|
20
|
|
91
|
use warnings; |
|
|
20
|
|
|
|
|
33
|
|
|
|
20
|
|
|
|
|
8897
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
13
|
|
|
13
|
0
|
4673
|
sub new { bless {index=>0}, shift } |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub all { |
|
12
|
4
|
|
|
4
|
0
|
3605
|
my ($self, $cb) = @_; |
|
13
|
|
|
|
|
|
|
|
|
14
|
4
|
|
|
|
|
6
|
my $docs = undef; |
|
15
|
4
|
|
|
|
|
4
|
my $err = undef; |
|
16
|
|
|
|
|
|
|
|
|
17
|
4
|
100
|
|
|
|
12
|
if (defined $Test::Mock::Mango::error) { |
|
18
|
2
|
|
|
|
|
3
|
$err = $Test::Mock::Mango::error; |
|
19
|
2
|
|
|
|
|
3
|
$Test::Mock::Mango::error = undef; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
else { |
|
22
|
2
|
|
|
|
|
9
|
$docs = $Test::Mock::Mango::data->{collection}; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
4
|
100
|
|
|
|
15
|
return $cb->($self,$err,$docs) if $cb; |
|
26
|
2
|
|
|
|
|
11
|
return $docs; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Naive no-op. Just return the parent so it can chain. |
|
32
|
1
|
|
|
1
|
0
|
1393
|
sub limit { shift } |
|
33
|
1
|
|
|
1
|
0
|
1572
|
sub sort { shift } |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Naive "next" - simply iterate through the docs in the defined test data |
|
38
|
|
|
|
|
|
|
sub next { |
|
39
|
14
|
|
|
14
|
0
|
2211
|
my ($self, $cb) = @_; |
|
40
|
|
|
|
|
|
|
|
|
41
|
14
|
|
|
|
|
15
|
my $doc = undef; |
|
42
|
14
|
|
|
|
|
15
|
my $err = undef; |
|
43
|
|
|
|
|
|
|
|
|
44
|
14
|
100
|
|
|
|
28
|
if (defined $Test::Mock::Mango::error) { |
|
45
|
2
|
|
|
|
|
3
|
$err = $Test::Mock::Mango::error; |
|
46
|
2
|
|
|
|
|
3
|
$Test::Mock::Mango::error = undef; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
else { |
|
49
|
12
|
|
|
|
|
50
|
$doc = $Test::Mock::Mango::data->{collection}->[$self->{index}++]; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
14
|
100
|
|
|
|
41
|
return $cb->($self,$err,$doc) if $cb; |
|
53
|
7
|
|
|
|
|
33
|
return $doc; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub count { |
|
59
|
4
|
|
|
4
|
0
|
4932
|
my ($self,$cb) = @_; |
|
60
|
|
|
|
|
|
|
|
|
61
|
4
|
|
|
|
|
5
|
my $count = undef; |
|
62
|
4
|
|
|
|
|
6
|
my $err = undef; |
|
63
|
|
|
|
|
|
|
|
|
64
|
4
|
100
|
|
|
|
12
|
if (defined $Test::Mock::Mango::error) { |
|
65
|
2
|
|
|
|
|
4
|
$err = $Test::Mock::Mango::error; |
|
66
|
2
|
|
|
|
|
3
|
$Test::Mock::Mango::error = undef; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
else { |
|
69
|
2
|
|
|
|
|
3
|
$count = scalar @{$Test::Mock::Mango::data->{collection}}; |
|
|
2
|
|
|
|
|
17
|
|
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
4
|
100
|
|
|
|
15
|
return $cb->($self,$err,$count) if $cb; |
|
73
|
2
|
|
|
|
|
8
|
return $count; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub backlog { |
|
79
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
80
|
0
|
|
|
|
|
|
return 2; # Arbitary for a valid call |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=encoding utf8 |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 NAME |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Test::Mock::Mango::Cursor - fake Mango::Cursor |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Simulated mango cursor for unit testing as part of L. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |