1 | #include "catch.hpp" |
2 | #include "duckdb/common/file_system.hpp" |
3 | #include "test_helpers.hpp" |
4 | |
5 | using namespace duckdb; |
6 | using namespace std; |
7 | |
8 | TEST_CASE("Create and drop a schema+table over different runs" , "[storage]" ) { |
9 | unique_ptr<QueryResult> result; |
10 | auto storage_database = TestCreatePath("storage_test" ); |
11 | auto config = GetTestConfig(); |
12 | |
13 | // make sure the database does not exist |
14 | DeleteDatabase(storage_database); |
15 | { |
16 | // create a database and insert values |
17 | DuckDB db(storage_database, config.get()); |
18 | Connection con(db); |
19 | REQUIRE_NO_FAIL(con.Query("CREATE SCHEMA test;" )); |
20 | REQUIRE_NO_FAIL(con.Query("CREATE TABLE test.test (a INTEGER, b INTEGER);" )); |
21 | REQUIRE_NO_FAIL(con.Query("INSERT INTO test.test VALUES (11, 22), (13, 22);" )); |
22 | REQUIRE_NO_FAIL(con.Query("DROP TABLE test.test" )); |
23 | REQUIRE_NO_FAIL(con.Query("DROP SCHEMA test" )); |
24 | |
25 | REQUIRE_NO_FAIL(con.Query("CREATE SCHEMA test;" )); |
26 | REQUIRE_NO_FAIL(con.Query("CREATE TABLE test.test (a INTEGER, b INTEGER);" )); |
27 | REQUIRE_NO_FAIL(con.Query("INSERT INTO test.test VALUES (11, 22), (13, 22);" )); |
28 | } |
29 | // reload the database from disk |
30 | { |
31 | DuckDB db(storage_database, config.get()); |
32 | Connection con(db); |
33 | REQUIRE_NO_FAIL(con.Query("DROP TABLE test.test" )); |
34 | REQUIRE_NO_FAIL(con.Query("DROP SCHEMA test" )); |
35 | } |
36 | DeleteDatabase(storage_database); |
37 | } |
38 | |