diff options
| author | Paul Buetow <paul@buetow.org> | 2015-01-02 14:00:56 +0100 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2015-01-02 14:00:56 +0100 |
| commit | 4f27f3ea59baa6cfca0ac1df96b1dfedbd83706c (patch) | |
| tree | 79754e3c49216f80cb3ad5579851fca0bf1a31c9 /t/update_format.t | |
initial
Diffstat (limited to 't/update_format.t')
| -rw-r--r-- | t/update_format.t | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/t/update_format.t b/t/update_format.t new file mode 100644 index 0000000..248dd17 --- /dev/null +++ b/t/update_format.t @@ -0,0 +1,37 @@ +#!/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 and _FOO = foo and _BAR = bar`; +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 and _FOO = foo and _BAR = bar`; +cmp_ok($json->{message}, 'eq', '1 changes successfully commited', 'Testing insert'); + +$json = decode_json `./mon --nocolor -m update host set _BEER = '\@_FOO' and _PIZZA = '\$_BAR' and _COLA = '\${_FOO}foo\@{_BAR}bar' where name like footest and host_name like server.lan`; +cmp_ok($json->{message}, 'eq', '2 changes successfully commited', 'Testing expression in update ... set'); + +$json = decode_json `./mon --nocolor -m get host where name like footest and host_name like server.lan`; +cmp_ok($json->[0]{_BEER}, 'eq', 'foo', 'Testing get after a update'); +cmp_ok($json->[1]{_BEER}, 'eq', 'foo', 'Testing get after a update'); +cmp_ok($json->[0]{_PIZZA}, 'eq', 'bar', 'Testing get after a update'); +cmp_ok($json->[1]{_PIZZA}, 'eq', 'bar', 'Testing get after a update'); +cmp_ok($json->[0]{_COLA}, 'eq', 'foofoobarbar', 'Testing get after a update'); +cmp_ok($json->[1]{_COLA}, 'eq', 'foofoobarbar', 'Testing get after a update'); + +$json = decode_json `./mon --nocolor delete host where name like footest01.server.lan`; +cmp_ok($json->{message}, 'eq', '1 changes successfully commited', 'Testing put'); + +$json = decode_json `./mon --nocolor delete host where name like footest02.server.lan`; +cmp_ok($json->{message}, 'eq', '1 changes successfully commited', 'Testing put'); + +done_testing(); + |
