forked from munin-monitoring/munin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmunin_node_configure_history.t
103 lines (81 loc) · 1.74 KB
/
munin_node_configure_history.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
use strict;
use warnings;
use Test::More tests => 7;
use File::Temp qw( tempfile );
use Munin::Node::Configure::Plugin;
use_ok 'Munin::Node::Configure::History';
my ($fh, $history_file) = tempfile( UNLINK => 1);
print {$fh} <<'EOH';
#
# This file contains a test plugin history.
#
[0.0.0]
[0.9.2]
[0.9.7]
[0.9.8]
df
df_inode
freebsd/df_inode
freebsd/open_files
linux/cpu
[0.9.9pre1]
[0.9.9pre2]
squid_cache
tomcat_volume
[1.3.3]
users
[1.3.4]
colour_tester
squid_objectsize
EOH
close $fh;
### tests start here ###########################################################
### new
{
new_ok('Munin::Node::Configure::History' => [
history_file => '/usr/share/munin/plugins/plugins.history',
]);
}
{
eval { Munin::Node::Configure::History->new(newer => '1.2.3') };
like($@, qr/history/, 'Error if no history file is specified');
}
### load
{
# no history file
my $hist = Munin::Node::Configure::History->new(
history_file => '/foo/blort',
newer => '1.3.4',
);
eval { $hist->load };
ok($@, 'Dies if history file is non-existent');
}
{
my $hist = Munin::Node::Configure::History->new(
history_file => '/foo/blort',
);
eval { $hist->load };
unlike($@, qr/./, 'File is not read when --newer was not specified');
}
{
my $hist = Munin::Node::Configure::History->new(
history_file => $history_file,
newer => '1.3.3',
);
$hist->load;
is_deeply(
[ sort keys %{$hist->{valid_plugins}} ],
[qw/colour_tester squid_objectsize/],
'Got the right plugins'
);
}
{
my $hist = Munin::Node::Configure::History->new(
history_file => $history_file,
newer => '31.3.3',
);
eval { $hist->load };
ok($@, 'Dies with invalid version number.');
}
# TODO: test platform-detection
### too_old