[icinga-checkins] icinga.org: icingaweb2-module-director/master: IcingaServiceTest: re-add tests lost on rebase

git at icinga.org git at icinga.org
Tue Oct 25 04:39:56 CEST 2016


Module: icingaweb2-module-director
Branch: master
Commit: 5d693debeb8c17c66f12b89e460fde2bf7410278
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=5d693debeb8c17c66f12b89e460fde2bf7410278

Author: Thomas Gelf <thomas at gelf.net>
Date:   Sat Oct 22 06:23:59 2016 +0000

IcingaServiceTest: re-add tests lost on rebase

---

 .../library/Director/Objects/IcingaServiceTest.php |   26 +++++++++++++++++++-
 .../library/Director/Objects/rendered/service3.out |   16 ++++++++++++
 .../library/Director/Objects/rendered/service5.out |   15 +++++++++++
 3 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/test/php/library/Director/Objects/IcingaServiceTest.php b/test/php/library/Director/Objects/IcingaServiceTest.php
index 45a1823..276d671 100644
--- a/test/php/library/Director/Objects/IcingaServiceTest.php
+++ b/test/php/library/Director/Objects/IcingaServiceTest.php
@@ -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(
diff --git a/test/php/library/Director/Objects/rendered/service3.out b/test/php/library/Director/Objects/rendered/service3.out
new file mode 100644
index 0000000..ad39128
--- /dev/null
+++ b/test/php/library/Director/Objects/rendered/service3.out
@@ -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
+}
+
diff --git a/test/php/library/Director/Objects/rendered/service5.out b/test/php/library/Director/Objects/rendered/service5.out
new file mode 100644
index 0000000..d1b0573
--- /dev/null
+++ b/test/php/library/Director/Objects/rendered/service5.out
@@ -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
+}
+



More information about the icinga-checkins mailing list