view libirccd-test/irccd/plugin_test.hpp @ 534:2326a4dc39e6

Irccd: rewrite transports in Boost.Asio, closes #681
author David Demelier <markand@malikania.fr>
date Fri, 17 Nov 2017 20:56:10 +0100
parents b3a0f61a35fe
children 986ed3a7575d
line wrap: on
line source

/*
 * plugin_test.hpp -- test fixture helper for Javascript plugins
 *
 * Copyright (c) 2013-2017 David Demelier <markand@malikania.fr>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef IRCCD_PLUGIN_TEST_HPP
#define IRCCD_PLUGIN_TEST_HPP

/**
 * \file plugin_test.hpp
 * \brief test fixture helper for Javascript plugins.
 */

#include <boost/asio/io_service.hpp>

#include <js/js_plugin.hpp>

#include "irccd.hpp"
#include "journal_server.hpp"

namespace irccd {

/**
 * \brief test fixture helper for Javascript plugins.
 *
 * Holds a plugin that is opened (but not loaded).
 */
class plugin_test {
protected:
    boost::asio::io_service service_;
    irccd irccd_{service_};
    std::shared_ptr<js_plugin> plugin_;
    std::shared_ptr<journal_server> server_;

public:
    /**
     * Construct the fixture test.
     *
     * \param name the plugin name (e.g. ask)
     * \param path the full plugin path (e.g. /usr/libexec/irccd/plugins/ask.js)
     */
    plugin_test(std::string name, std::string path);
};

} // !irccd

#endif // !IRCCD_PLUGIN_TESTER_HPP