IcingaServiceTest: re-add tests lost on rebase

This commit is contained in:
Thomas Gelf 2016-10-22 06:23:59 +00:00
parent 1f660b514a
commit 5d693debeb
3 changed files with 56 additions and 1 deletions

View File

@ -253,8 +253,9 @@ class IcingaServiceTest extends BaseTestCase
$service->store($db);
$service = IcingaService::loadWithAutoIncId($service->id, $db);
$this->assertEquals(
$this->loadRendered('service5'),
$this->loadRendered('service3'),
(string) $service
);
}
@ -280,6 +281,29 @@ class IcingaServiceTest extends BaseTestCase
);
}
public function testApplyFor()
{
if ($this->skipForMissingDb()) {
return;
}
$db = $this->getDb();
$service = $this->service();
$service->object_type = 'apply';
$service->apply_for = 'host.vars.test1';
$service->assignments = array(
'host.vars.env="test"'
);
$service->store($db);
$service = IcingaService::loadWithAutoIncId($service->id, $db);
$this->assertEquals(
$this->loadRendered('service5'),
(string) $service
);
}
protected function host()
{
return IcingaHost::create(array(

View File

@ -0,0 +1,16 @@
apply Service "___TEST___service_$not_replaced$" {
display_name = "Service: " + host.vars.replaced
vars.custom_var = host.vars.replaced
vars.test1 = "string"
vars.test2 = 17
vars.test3 = false
vars.test4 = {
a = [ "dict", "ionary" ]
@this = "is"
}
assign where match("127.*", host.address)
import DirectorOverrideTemplate
}

View File

@ -0,0 +1,15 @@
apply Service "___TEST___service" for (config in host.vars.test1) {
display_name = "Whatever service"
vars.test1 = "string"
vars.test2 = 17
vars.test3 = false
vars.test4 = {
a = [ "dict", "ionary" ]
@this = "is"
}
assign where host.vars.env == "test"
import DirectorOverrideTemplate
}