mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 17:24:18 +02:00
IcingaServiceTest: re-add tests lost on rebase
This commit is contained in:
parent
1f660b514a
commit
5d693debeb
@ -253,8 +253,9 @@ class IcingaServiceTest extends BaseTestCase
|
|||||||
$service->store($db);
|
$service->store($db);
|
||||||
|
|
||||||
$service = IcingaService::loadWithAutoIncId($service->id, $db);
|
$service = IcingaService::loadWithAutoIncId($service->id, $db);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$this->loadRendered('service5'),
|
$this->loadRendered('service3'),
|
||||||
(string) $service
|
(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()
|
protected function host()
|
||||||
{
|
{
|
||||||
return IcingaHost::create(array(
|
return IcingaHost::create(array(
|
||||||
|
16
test/php/library/Director/Objects/rendered/service3.out
Normal file
16
test/php/library/Director/Objects/rendered/service3.out
Normal 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
|
||||||
|
}
|
||||||
|
|
15
test/php/library/Director/Objects/rendered/service5.out
Normal file
15
test/php/library/Director/Objects/rendered/service5.out
Normal 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
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user