MXS-1461 Add general purpose mocking functions

This commit is contained in:
Johan Wikman
2017-11-14 13:32:59 +02:00
parent e434c7ec66
commit 65cf491350
2 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,54 @@
#pragma once
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2020-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#include <maxscale/cppdefs.hh>
#include <string>
#include <string.h>
#include <maxscale/buffer.h>
#include <maxscale/modutil.h>
namespace maxscale
{
namespace mock
{
/**
* Create a COM_QUERY packet containing the provided statement.
*
* @param zStatement Null terminated string containing an SQL statement.
*
* @return A buffer containing a COM_QUERY packet.
*/
inline GWBUF* create_com_query(const char* zStatement)
{
return modutil_create_query(zStatement);
}
/**
* Create a COM_QUERY packet containing the provided statement.
*
* @param statement String containing an SQL statement.
*
* @return A buffer containing a COM_QUERY packet.
*/
inline GWBUF* create_com_query(const std::string& statement)
{
return create_com_query(statement.c_str());
}
}
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2020-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#include "maxscale/mock/mock.hh"
#include <maxscale/protocol/mysql.h>
namespace maxscale
{
namespace mock
{
}
}