| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package XAO::testcases::FS::base; |
|
2
|
13
|
|
|
13
|
|
103
|
use strict; |
|
|
13
|
|
|
|
|
33
|
|
|
|
13
|
|
|
|
|
398
|
|
|
3
|
13
|
|
|
13
|
|
91
|
use XAO::Utils; |
|
|
13
|
|
|
|
|
25
|
|
|
|
13
|
|
|
|
|
764
|
|
|
4
|
13
|
|
|
13
|
|
1110
|
use XAO::Objects; |
|
|
13
|
|
|
|
|
10638
|
|
|
|
13
|
|
|
|
|
370
|
|
|
5
|
13
|
|
|
13
|
|
6030
|
use XAO::testcases::base; |
|
|
13
|
|
|
|
|
121690
|
|
|
|
13
|
|
|
|
|
448
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
13
|
|
|
13
|
|
202
|
use base qw(XAO::testcases::base); |
|
|
13
|
|
|
|
|
50
|
|
|
|
13
|
|
|
|
|
8712
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new ($) { |
|
10
|
13
|
|
|
13
|
0
|
2462
|
my $proto=shift; |
|
11
|
13
|
|
|
|
|
102
|
my $self=$proto->SUPER::new(@_); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Reading configuration |
|
14
|
|
|
|
|
|
|
# |
|
15
|
13
|
|
|
|
|
193
|
my %d; |
|
16
|
13
|
50
|
|
|
|
576
|
if(open(F,'.config')) { |
|
17
|
13
|
|
|
|
|
85
|
local($/); |
|
18
|
13
|
|
|
|
|
441
|
my $t=; |
|
19
|
13
|
|
|
|
|
157
|
close(F); |
|
20
|
13
|
|
|
|
|
908
|
eval $t; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
13
|
50
|
33
|
|
|
196
|
(!$@ && $d{'test_dsn'}) || |
|
24
|
|
|
|
|
|
|
die "Invalid config, re-run 'perl Makefile.PL'\n"; |
|
25
|
|
|
|
|
|
|
|
|
26
|
13
|
|
|
|
|
93
|
$self->{'dbconfig'}=\%d; |
|
27
|
|
|
|
|
|
|
|
|
28
|
13
|
50
|
|
|
|
49
|
if($d{'test_dsn'} eq 'none') { |
|
29
|
13
|
|
|
|
|
59
|
dprint "No DSN configured, skipping all tests"; |
|
30
|
13
|
|
|
|
|
53
|
$self->{'skip_db_tests'}=1; |
|
31
|
13
|
|
|
|
|
165
|
return; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
return $self; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub list_tests ($) { |
|
38
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
if($self->{'skip_db_tests'}) { |
|
41
|
0
|
0
|
|
|
|
|
return wantarray ? () : []; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
else { |
|
44
|
0
|
|
|
|
|
|
return $self->SUPER::list_tests(@_); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub reconnect ($) { |
|
49
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $dbconfig=$self->{'dbconfig'}; |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$self->assert($dbconfig->{'test_dsn'}, |
|
54
|
|
|
|
|
|
|
"No test configuration available (no .config)"); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$self->{'odb'}=XAO::Objects->new( |
|
57
|
|
|
|
|
|
|
objname => 'FS::Glue', |
|
58
|
|
|
|
|
|
|
dsn => $dbconfig->{'test_dsn'}, |
|
59
|
|
|
|
|
|
|
user => $dbconfig->{'test_user'}, |
|
60
|
0
|
|
|
|
|
|
password => $dbconfig->{'test_password'}, |
|
61
|
|
|
|
|
|
|
check_consistency => 1, |
|
62
|
|
|
|
|
|
|
); |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return $self->get_odb; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub set_up ($) { |
|
68
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
### $self->SUPER::set_up(@_); |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $dbconfig=$self->{'dbconfig'}; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
$self->assert($dbconfig->{'test_dsn'}, |
|
75
|
|
|
|
|
|
|
"No test configuration available (no .config)"); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$self->{'odb'}=XAO::Objects->new( |
|
78
|
|
|
|
|
|
|
objname => 'FS::Glue', |
|
79
|
|
|
|
|
|
|
dsn => $dbconfig->{'test_dsn'}, |
|
80
|
|
|
|
|
|
|
user => $dbconfig->{'test_user'}, |
|
81
|
0
|
|
|
|
|
|
password => $dbconfig->{'test_password'}, |
|
82
|
|
|
|
|
|
|
empty_database => 'confirm', |
|
83
|
|
|
|
|
|
|
check_consistency => 1, |
|
84
|
|
|
|
|
|
|
); |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
$self->assert($self->{odb}, "Can't connect to the FS database"); |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$self->{'odb_args'}={ |
|
89
|
|
|
|
|
|
|
dsn => $dbconfig->{'test_dsn'}, |
|
90
|
|
|
|
|
|
|
user => $dbconfig->{'test_user'}, |
|
91
|
0
|
|
|
|
|
|
password => $dbconfig->{'test_password'}, |
|
92
|
|
|
|
|
|
|
}; |
|
93
|
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
my $global=$self->{'odb'}->fetch('/'); |
|
95
|
0
|
|
|
|
|
|
$self->assert($global, "Can't fetch Global from FS database"); |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$global->build_structure( |
|
98
|
|
|
|
|
|
|
Customers => { |
|
99
|
|
|
|
|
|
|
type => 'list', |
|
100
|
|
|
|
|
|
|
class => 'Data::Customer', |
|
101
|
|
|
|
|
|
|
key => 'customer_id', |
|
102
|
|
|
|
|
|
|
structure => { |
|
103
|
|
|
|
|
|
|
name => { |
|
104
|
|
|
|
|
|
|
type => 'text', |
|
105
|
|
|
|
|
|
|
maxlength => 40, |
|
106
|
|
|
|
|
|
|
}, |
|
107
|
|
|
|
|
|
|
}, |
|
108
|
|
|
|
|
|
|
}, |
|
109
|
|
|
|
|
|
|
); |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my $clist=$self->{odb}->fetch('/Customers'); |
|
112
|
0
|
|
|
|
|
|
$self->assert($clist, "Can't fetch /Customers from FS database"); |
|
113
|
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
my $customer=$clist->get_new(); |
|
115
|
0
|
|
|
|
|
|
$self->assert(ref($customer), "Can't create new Data::Customer"); |
|
116
|
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
$customer->put(name => 'Test Customer #1'); |
|
118
|
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
$clist->put(c1 => $customer); |
|
120
|
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
$customer->put(name => 'Test Customer #2'); |
|
122
|
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
$clist->put(c2 => $customer); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub tear_down { |
|
127
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
### $self->SUPER::tear_down(@_); |
|
130
|
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
$self->{odb}=undef; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub get_odb { |
|
135
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
|
136
|
0
|
|
|
|
|
|
my $odb=$self->{'odb'}; |
|
137
|
0
|
|
0
|
|
|
|
$self->assert(defined($odb) && ref($odb), 'No object database handler'); |
|
138
|
0
|
|
|
|
|
|
$odb; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
13
|
|
|
13
|
|
107
|
use vars qw(*SE); |
|
|
13
|
|
|
|
|
26
|
|
|
|
13
|
|
|
|
|
1640
|
|
|
142
|
|
|
|
|
|
|
sub stderr_stop { |
|
143
|
0
|
|
|
0
|
0
|
|
open(SE,">&STDERR"); |
|
144
|
0
|
|
|
|
|
|
open(STDERR,">/dev/null"); |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub stderr_restore { |
|
148
|
0
|
|
|
0
|
0
|
|
open(STDERR,">&SE"); |
|
149
|
0
|
|
|
|
|
|
close(SE); |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
1; |