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
|
#!/usr/bin/perl
use strict;
use warnings;
use v5.10;
use JSON;
use Test::More;
chdir '..';
my $json;
$json = decode_json `./mon --nocolor insert host set use = generic-host and name = footest.server.lan and host_name = footest.server.lan and address = 127.0.0.1 and _FOO = foo and _BAR = bar`;
cmp_ok($json->{message}, 'eq', '1 changes successfully commited', 'Testing insert');
$json = decode_json `./mon --nocolor update host delete _FOO where name like footest.server.lan`;
cmp_ok($json->{message}, 'eq', '1 changes successfully commited', 'Testing update ... delete');
$json = decode_json `./mon --nocolor -m get host where name like footest.server.lan`;
cmp_ok(exists $json->[0]{_FOO}, '==', 0, 'Testing get after a update');
cmp_ok($json->[0]{_BAR}, 'eq', 'bar', 'Testing get after a update');
$json = decode_json `./mon --nocolor update host set _FOO = fuu where name like footest.server.lan`;
cmp_ok($json->{message}, 'eq', '1 changes successfully commited', 'Testing update ... set');
$json = decode_json `./mon --nocolor -m get host where name like footest.server.lan`;
cmp_ok($json->[0]{_FOO}, 'eq', 'fuu', 'Testing get after a update');
$json = decode_json `./mon --nocolor update host set _ONE = one and _TWO = two where name like footest.server.lan`;
cmp_ok($json->{message}, 'eq', '1 changes successfully commited', 'Testing update ... set with multiple objects');
$json = decode_json `./mon --nocolor -m get host where name like footest.server.lan`;
cmp_ok($json->[0]{_FOO}, 'eq', 'fuu', 'Testing get after a update');
cmp_ok($json->[0]{_BAR}, 'eq', 'bar', 'Testing get after a update');
cmp_ok($json->[0]{_ONE}, 'eq', 'one', 'Testing get after a update');
cmp_ok($json->[0]{_TWO}, 'eq', 'two', 'Testing get after a update');
$json = decode_json `./mon --nocolor update host delete _FOO and _BAR where name like footest.server.lan`;
cmp_ok($json->{message}, 'eq', '1 changes successfully commited', 'Testing update ... delete with multiple arguments');
$json = decode_json `./mon --nocolor -m get host where name like footest.server.lan`;
cmp_ok(exists $json->[0]{_FOO}, '==', 0, 'Testing get after a update');
cmp_ok(exists $json->[0]{_BAR}, '==', 0, 'Testing get after a update');
$json = decode_json `./mon --nocolor delete host where name like footest.server.lan`;
cmp_ok($json->{message}, 'eq', '1 changes successfully commited', 'Testing put');
done_testing();
|