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
|
#!/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 = footest01.server.lan and host_name = footest01.server.lan and address = 127.0.0.1`;
cmp_ok($json->{message}, 'eq', '1 changes successfully commited', 'Testing insert');
$json = decode_json `./mon --nocolor insert host set use = generic-host and name = footest02.server.lan and host_name = footest02.server.lan and address = 127.0.0.1`;
cmp_ok($json->{message}, 'eq', '1 changes successfully commited', 'Testing insert');
$json = decode_json `./mon --nocolor delete host where name like 'footest01.server.lan'`;
cmp_ok($json->{message}, 'eq', '1 changes successfully commited', 'Testing delete');
$json = decode_json `./mon --nocolor delete host where name like 'footest02.server.lan'`;
cmp_ok($json->{message}, 'eq', '1 changes successfully commited', 'Testing delete');
$json = decode_json `./mon --nocolor get host where name matches 'footest..\\.server\\.lan'`;
cmp_ok(scalar @$json, 'eq', 0, 'Testing get after delete');
done_testing();
|