From 46efb072856de6452781f917a4addb9528ab2cf9 Mon Sep 17 00:00:00 2001 From: Oliver Giles Date: Sat, 3 Feb 2018 16:47:41 +0200 Subject: [PATCH] test: add LaminarTest stub --- CMakeLists.txt | 4 ++-- src/laminar.cpp | 2 ++ test/test-laminar.cpp | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 test/test-laminar.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a151dc2..27582dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,8 +93,8 @@ set(BUILD_TESTS FALSE CACHE BOOL "Build tests") if(BUILD_TESTS) find_package(GTest REQUIRED) include_directories(${GTEST_INCLUDE_DIRS} src) - add_executable(laminar-tests src/conf.cpp src/database.cpp src/run.cpp src/server.cpp laminar.capnp.c++ src/resources.cpp ${COMPRESSED_BINS} test/test-conf.cpp test/test-database.cpp test/test-run.cpp test/test-server.cpp) - target_link_libraries(laminar-tests ${GTEST_BOTH_LIBRARIES} gmock capnp-rpc capnp kj-async kj pthread boost_filesystem boost_system sqlite3) + add_executable(laminar-tests src/conf.cpp src/database.cpp src/laminar.cpp src/run.cpp src/server.cpp laminar.capnp.c++ src/resources.cpp ${COMPRESSED_BINS} test/test-conf.cpp test/test-database.cpp test/test-laminar.cpp test/test-run.cpp test/test-server.cpp) + target_link_libraries(laminar-tests ${GTEST_BOTH_LIBRARIES} gmock capnp-rpc capnp kj-async kj pthread boost_filesystem boost_system sqlite3 z) endif() install(TARGETS laminard laminarc RUNTIME DESTINATION usr/bin) diff --git a/src/laminar.cpp b/src/laminar.cpp index 06e4069..8010115 100644 --- a/src/laminar.cpp +++ b/src/laminar.cpp @@ -91,6 +91,8 @@ Laminar::Laminar() { buildNums[name] = build; }); + srv = nullptr; + // This is only a separate function because I imagined that it would // be nice to reload some configuration during runtime without restarting // the server completely. Currently not called from anywhere else diff --git a/test/test-laminar.cpp b/test/test-laminar.cpp new file mode 100644 index 0000000..af5053f --- /dev/null +++ b/test/test-laminar.cpp @@ -0,0 +1,34 @@ +/// +/// Copyright 2018 Oliver Giles +/// +/// This file is part of Laminar +/// +/// Laminar is free software: you can redistribute it and/or modify +/// it under the terms of the GNU General Public License as published by +/// the Free Software Foundation, either version 3 of the License, or +/// (at your option) any later version. +/// +/// Laminar is distributed in the hope that it will be useful, +/// but WITHOUT ANY WARRANTY; without even the implied warranty of +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +/// GNU General Public License for more details. +/// +/// You should have received a copy of the GNU General Public License +/// along with Laminar. If not, see +/// +#include +#include +#include +#include "laminar.h" + +class TestLaminarClient : public LaminarClient { +public: + virtual void sendMessage(std::string p) { payload = p; } + std::string payload; +}; + +class LaminarTest : public ::testing::Test { +protected: + Laminar laminar; +}; +