summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorMahmoud Mandour <ma.mandourr@gmail.com>2021-09-17 20:35:55 +0200
committerAndreas Kling <kling@serenityos.org>2021-10-04 15:51:48 +0200
commit6065383e051e87c7e2be8d4f63dc03e9ac78bd79 (patch)
tree234ef1c846dcdb15fec1a23607e700624c4481b8 /Tests
parent0906e3c20661f357ebe808274568ed18c35d9a40 (diff)
downloadserenity-6065383e051e87c7e2be8d4f63dc03e9ac78bd79.zip
LibSQL: Check NoError individually in execution tests
This enables tests to check that a statement is erroneous, we could not do so by only calling `execute()` since it asserted that no errors occurred.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/LibSQL/TestSqlStatementExecution.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/Tests/LibSQL/TestSqlStatementExecution.cpp b/Tests/LibSQL/TestSqlStatementExecution.cpp
index 4f202b1270..28169553c5 100644
--- a/Tests/LibSQL/TestSqlStatementExecution.cpp
+++ b/Tests/LibSQL/TestSqlStatementExecution.cpp
@@ -28,13 +28,13 @@ RefPtr<SQL::SQLResult> execute(NonnullRefPtr<SQL::Database> database, String con
}
SQL::AST::ExecutionContext context { database };
auto result = statement->execute(context);
- EXPECT(result->error().code == SQL::SQLErrorCode::NoError);
return result;
}
void create_schema(NonnullRefPtr<SQL::Database> database)
{
auto result = execute(database, "CREATE SCHEMA TestSchema;");
+ EXPECT(result->error().code == SQL::SQLErrorCode::NoError);
EXPECT(result->inserted() == 1);
}
@@ -42,6 +42,7 @@ void create_table(NonnullRefPtr<SQL::Database> database)
{
create_schema(database);
auto result = execute(database, "CREATE TABLE TestSchema.TestTable ( TextColumn text, IntColumn integer );");
+ EXPECT(result->error().code == SQL::SQLErrorCode::NoError);
EXPECT(result->inserted() == 1);
}
@@ -69,6 +70,7 @@ TEST_CASE(insert_into_table)
auto database = SQL::Database::construct(db_name);
create_table(database);
auto result = execute(database, "INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test', 42 );");
+ EXPECT(result->error().code == SQL::SQLErrorCode::NoError);
EXPECT(result->inserted() == 1);
auto table = database->get_table("TESTSCHEMA", "TESTTABLE");
@@ -88,12 +90,16 @@ TEST_CASE(select_from_table)
auto database = SQL::Database::construct(db_name);
create_table(database);
auto result = execute(database, "INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_1', 42 ), ( 'Test_2', 43 );");
+ EXPECT(result->error().code == SQL::SQLErrorCode::NoError);
EXPECT(result->inserted() == 2);
result = execute(database, "INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_3', 44 ), ( 'Test_4', 45 );");
+ EXPECT(result->error().code == SQL::SQLErrorCode::NoError);
EXPECT(result->inserted() == 2);
result = execute(database, "INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_5', 46 );");
+ EXPECT(result->error().code == SQL::SQLErrorCode::NoError);
EXPECT(result->inserted() == 1);
result = execute(database, "SELECT * FROM TestSchema.TestTable;");
+ EXPECT(result->error().code == SQL::SQLErrorCode::NoError);
EXPECT(result->has_results());
EXPECT_EQ(result->results().size(), 5u);
}