Skip to content

Commit

Permalink
refactor more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ray6080 committed Aug 6, 2023
1 parent 0b1f168 commit 9159769
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
22 changes: 0 additions & 22 deletions test/runner/e2e_copy_transaction_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,27 +212,5 @@ TEST_F(TinySnbCopyCSVTransactionTest, CopyRelCommitRecovery) {
copyRelCSVCommitAndRecoveryTest(TransactionTestType::RECOVERY);
}

TEST_F(TinySnbCopyCSVTransactionTest, CopyNodeOutputMsg) {
conn->query(createPersonTableCMD);
conn->query(createKnowsTableCMD);
auto result = conn->query(copyPersonTableCMD);
ASSERT_EQ(TestHelper::convertResultToString(*result),
std::vector<std::string>{"8 number of tuples has been copied to table: person."});
result = conn->query(copyKnowsTableCMD);
ASSERT_EQ(TestHelper::convertResultToString(*result),
std::vector<std::string>{"14 number of tuples has been copied to table: knows."});
}

TEST_F(TinySnbCopyCSVTransactionTest, CopyCSVStatementWithActiveTransactionErrorTest) {
auto re = conn->query(createPersonTableCMD);
ASSERT_TRUE(re->isSuccess());
conn->beginWriteTransaction();
auto result = conn->query(copyPersonTableCMD);
ASSERT_EQ(result->getErrorMessage(),
"DDL, CopyCSV, createMacro statements are automatically wrapped in a transaction and "
"committed. As such, they cannot be part of an active transaction, please commit or "
"rollback your previous transaction and issue a ddl query without opening a transaction.");
}

} // namespace testing
} // namespace kuzu
8 changes: 0 additions & 8 deletions test/runner/e2e_create_macro_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,5 @@ TEST_F(CreateMacroTestTrxTest, createMacroReadTrxError) {
"Can't execute a write query inside a read-only transaction.");
}

TEST_F(CreateMacroTestTrxTest, createMacroWithActiveTrxError) {
conn->beginWriteTransaction();
ASSERT_EQ(conn->query("CREATE MACRO var_macro(x) AS x")->getErrorMessage(),
"DDL, CopyCSV, createMacro statements are automatically wrapped in a transaction and "
"committed. As such, they cannot be part of an active transaction, please commit or "
"rollback your previous transaction and issue a ddl query without opening a transaction.");
}

} // namespace testing
} // namespace kuzu
24 changes: 24 additions & 0 deletions test/test_files/exceptions/copy/auto_commit.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-GROUP CopyAutoCommit
-DATASET CSV empty

--

-CASE CopyCSVStatementWithActiveTransactionError
-STATEMENT CREATE NODE TABLE person (ID INT64, fName STRING, gender INT64, isStudent BOOLEAN, isWorker BOOLEAN, age INT64, eyeSight DOUBLE, birthdate DATE, registerTime TIMESTAMP, lastJobDuration INTERVAL, workedHours INT64[], usedNames STRING[], courseScoresPerTerm INT64[][], grades INT64[4], height float, PRIMARY KEY (ID))
---- ok
-BEGIN_WRITE_TRANSACTION
-STATEMENT COPY person FROM "${KUZU_ROOT_DIRECTORY}/dataset/copy-fault-tests/duplicate-ids/vPerson.csv"
---- error
DDL, Copy, createMacro statements can only run in the AUTO_COMMIT mode. Please commit or rollback your previous transaction if there is any and issue the query without beginning a transaction

-CASE CopyNodeOutputMsg
-STATEMENT CREATE NODE TABLE person (ID INT64, fName STRING, gender INT64, isStudent BOOLEAN, isWorker BOOLEAN, age INT64, eyeSight DOUBLE, birthdate DATE, registerTime TIMESTAMP, lastJobDuration INTERVAL, workedHours INT64[], usedNames STRING[], courseScoresPerTerm INT64[][], grades INT64[4], height float, PRIMARY KEY (ID))
---- ok
-STATEMENT COPY person FROM "${KUZU_ROOT_DIRECTORY}/dataset/copy-fault-tests/duplicate-ids/vPerson.csv"
---- 1
8 number of tuples has been copied to table: person.
-STATEMENT CREATE REL TABLE knows (FROM person TO person, date DATE, meetTime TIMESTAMP, validInterval INTERVAL, comments STRING[], MANY_MANY)
---- ok
-STATEMENT COPY knows FROM "${KUZU_ROOT_DIRECTORY}/dataset/copy-fault-tests/duplicate-ids/vKnows.csv"
---- 1
14 number of tuples has been copied to table: knows.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-GROUP DDLActiveTransaction
-GROUP DDLAutoCommit
-DATASET CSV tinysnb

--
Expand All @@ -20,3 +20,9 @@ DDL, Copy, createMacro statements can only run in the AUTO_COMMIT mode. Please c
-STATEMENT ALTER TABLE person DROP gender
---- error
DDL, Copy, createMacro statements can only run in the AUTO_COMMIT mode. Please commit or rollback your previous transaction if there is any and issue the query without beginning a transaction

-CASE CreateMacroAutoTransactionError
-BEGIN_WRITE_TRANSACTION
-STATEMENT CREATE MACRO var_macro(x) AS x
---- error
DDL, Copy, createMacro statements can only run in the AUTO_COMMIT mode. Please commit or rollback your previous transaction if there is any and issue the query without beginning a transaction

0 comments on commit 9159769

Please sign in to comment.