MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
handler-t.cc
1 /* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 #include "handler-t.h"
17 #include "test_utils.h"
18 #include "fake_table.h"
19 #include "mock_field_datetime.h"
20 
21 #include "sql_executor.h"
22 
23 namespace {
24 
27 
28 using ::testing::StrictMock;
29 
30 class HandlerTest : public ::testing::Test
31 {
32 protected:
33  virtual void SetUp() { initializer.SetUp(); }
34  virtual void TearDown() { initializer.TearDown(); }
35 
36  THD *thd() { return initializer.thd(); }
37 
38  Server_initializer initializer;
39 };
40 
41 
49 TEST_F(HandlerTest, ReportErrorHandler)
50 {
51  Mock_field_datetime field_datetime;
52  Fake_TABLE table(&field_datetime);
53  handlerton *hton= NULL;
54  StrictMock<Mock_HANDLER> mock_handler(hton, table.get_share());
55  table.set_handler(&mock_handler);
56 
57  // This error should be ignored.
58  EXPECT_EQ(-1, report_handler_error(&table, HA_ERR_END_OF_FILE));
59 
60  // This one should not be printed to stderr, but passed on to the handler.
61  EXPECT_CALL(mock_handler, print_error(HA_ERR_TABLE_DEF_CHANGED, 0)).Times(1);
62  EXPECT_EQ(1, report_handler_error(&table, HA_ERR_TABLE_DEF_CHANGED));
63 }
64 
65 }