The Battle for Wesnoth  1.15.3+dev
AlterTableTest.cpp
Go to the documentation of this file.
1 //
2 // M A R I A D B + +
3 //
4 // Copyright The ViaDuck Project 2016 - 2018.
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 
9 #include "AlterTableTest.h"
10 
12  m_con->execute("CREATE TABLE " + m_table_name +
13  " (id INT AUTO_INCREMENT, PRIMARY KEY (`id`));");
14 }
15 
16 TEST_F(AlterTableTest, AlterAddAndDrop_existing) {
17  m_con->execute("ALTER TABLE " + m_table_name + " ADD new INT;");
18  m_con->execute("ALTER TABLE " + m_table_name + " DROP COLUMN new;");
19 }
20 
21 TEST_F(AlterTableTest, AlterAddAndModify_existing) {
22  m_con->execute("ALTER TABLE " + m_table_name + " ADD new INT;");
23  m_con->execute("ALTER TABLE " + m_table_name + " MODIFY new DOUBLE NOT NULL;");
24 }
25 
26 TEST_F(AlterTableTest, AlterAdd_non_existing_table) {
27  EXPECT_ANY_THROW(m_con->execute("ALTER TABLE doesntexist ADD new INT;"));
28 }
29 
30 TEST_F(AlterTableTest, AlterDrop_non_existing_table) {
31  EXPECT_ANY_THROW(m_con->execute("ALTER TABLE doesntexist DROP COLUMN new;"));
32 }
33 
34 TEST_F(AlterTableTest, AlterModify_non_existing_table) {
35  EXPECT_ANY_THROW(m_con->execute("ALTER TABLE doesntexist MODIFY new DOUBLE;"));
36 }
37 
38 TEST_F(AlterTableTest, AlterModify_non_existing_column) {
39  m_con->execute("ALTER TABLE " + m_table_name + " ADD new INT;");
40  EXPECT_ANY_THROW(
41  m_con->execute("ALTER TABLE " + m_table_name + " MODIFY new_doesntexist DOUBLE;"));
42 }
43 
44 TEST_F(AlterTableTest, AlterAddAndDrop_no_connect) {
45  account_ref no_acc = account::create("256.256.256.256", "", "");
46  connection_ref no_conn = connection::create(no_acc);
47 
48  EXPECT_ANY_THROW(no_conn->execute("ALTER TABLE " + m_table_name + " ADD new INT;"));
49  EXPECT_ANY_THROW(no_conn->execute("ALTER TABLE " + m_table_name + " DROP COLUMN new;"));
50 }
std::shared_ptr< account > account_ref
Definition: account.hpp:19
connection_ref m_con
Definition: SkeletonTest.h:56
TEST_F(AlterTableTest, AlterAddAndDrop_existing)
std::string m_table_name
Definition: SkeletonTest.h:54
std::shared_ptr< connection > connection_ref
Definition: statement.hpp:33
virtual void CreateTestTable() override