From 65cf4913506cdd644d12783e039def778d48e197 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 14 Nov 2017 13:32:59 +0200 Subject: [PATCH] MXS-1461 Add general purpose mocking functions --- .../dbfwfilter/test/maxscale/mock/mock.hh | 54 +++++++++++++++++++ server/modules/filter/dbfwfilter/test/mock.cc | 26 +++++++++ 2 files changed, 80 insertions(+) create mode 100644 server/modules/filter/dbfwfilter/test/maxscale/mock/mock.hh create mode 100644 server/modules/filter/dbfwfilter/test/mock.cc diff --git a/server/modules/filter/dbfwfilter/test/maxscale/mock/mock.hh b/server/modules/filter/dbfwfilter/test/maxscale/mock/mock.hh new file mode 100644 index 000000000..13fc42a53 --- /dev/null +++ b/server/modules/filter/dbfwfilter/test/maxscale/mock/mock.hh @@ -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 +#include +#include +#include +#include + + +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()); +} + +} + +} diff --git a/server/modules/filter/dbfwfilter/test/mock.cc b/server/modules/filter/dbfwfilter/test/mock.cc new file mode 100644 index 000000000..98827e2bc --- /dev/null +++ b/server/modules/filter/dbfwfilter/test/mock.cc @@ -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 + + +namespace maxscale +{ + +namespace mock +{ + +} + +}