1 /******************************************************************************
3 * Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software Foundation *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ******************************************************************************/
20 #include "config/configcompiler.hpp"
21 #include "config/configitem.hpp"
22 #include "base/application.hpp"
23 #include "base/loader.hpp"
24 #include "icingaapplication-fixture.hpp"
25 #include <BoostTestTargetConfig.h>
27 using namespace icinga;
29 struct LivestatusFixture
33 // ensure IcingaApplication is initialized before we try to add config
34 IcingaApplicationFixture icinga;
36 BOOST_TEST_MESSAGE("Preparing config objects...");
38 ConfigItem::RunWithActivationContext(new Function("CreateTestObjects", CreateTestObjects));
41 static void CreateTestObjects()
43 String config = R"CONFIG(
44 object CheckCommand "dummy" {
48 object Host "test-01" {
50 check_command = "dummy"
53 object Host "test-02" {
55 check_command = "dummy"
58 apply Service "livestatus" {
59 check_command = "dummy"
60 notes = "test livestatus"
61 assign where match("test-*", host.name)
65 std::unique_ptr<Expression> expr = ConfigCompiler::CompileText("<livestatus>", config);
66 expr->Evaluate(*ScriptFrame::GetCurrentFrame());
70 BOOST_GLOBAL_FIXTURE(LivestatusFixture);