diff options
author | coderdreams <coderdreams@gmail.com> | 2021-06-22 10:03:59 -0300 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-06-22 18:54:40 +0430 |
commit | 49340f98f785dde0544f36b5fa422266c77a0858 (patch) | |
tree | 5a9d25494c854a48c1c0c05019cad05be0c96dd3 | |
parent | 6bc7f2204e32fb5ef824fc7ccb5ce28335c606f8 (diff) | |
download | serenity-49340f98f785dde0544f36b5fa422266c77a0858.zip |
LibSQL: Create databases in writable directory
-rw-r--r-- | Tests/LibSQL/TestSqlBtreeIndex.cpp | 12 | ||||
-rw-r--r-- | Tests/LibSQL/TestSqlDatabase.cpp | 36 | ||||
-rw-r--r-- | Tests/LibSQL/TestSqlHashIndex.cpp | 12 |
3 files changed, 30 insertions, 30 deletions
diff --git a/Tests/LibSQL/TestSqlBtreeIndex.cpp b/Tests/LibSQL/TestSqlBtreeIndex.cpp index 73aa2af2ab..edb3a6b722 100644 --- a/Tests/LibSQL/TestSqlBtreeIndex.cpp +++ b/Tests/LibSQL/TestSqlBtreeIndex.cpp @@ -143,9 +143,9 @@ NonnullRefPtr<SQL::BTree> setup_btree(SQL::Heap& heap) void insert_and_get_to_and_from_btree(int num_keys) { - ScopeGuard guard([]() { unlink("test.db"); }); + ScopeGuard guard([]() { unlink("/tmp/test.db"); }); { - auto heap = SQL::Heap::construct("test.db"); + auto heap = SQL::Heap::construct("/tmp/test.db"); auto btree = setup_btree(heap); for (auto ix = 0; ix < num_keys; ix++) { @@ -160,7 +160,7 @@ void insert_and_get_to_and_from_btree(int num_keys) } { - auto heap = SQL::Heap::construct("test.db"); + auto heap = SQL::Heap::construct("/tmp/test.db"); auto btree = setup_btree(heap); for (auto ix = 0; ix < num_keys; ix++) { @@ -175,9 +175,9 @@ void insert_and_get_to_and_from_btree(int num_keys) void insert_into_and_scan_btree(int num_keys) { - ScopeGuard guard([]() { unlink("test.db"); }); + ScopeGuard guard([]() { unlink("/tmp/test.db"); }); { - auto heap = SQL::Heap::construct("test.db"); + auto heap = SQL::Heap::construct("/tmp/test.db"); auto btree = setup_btree(heap); for (auto ix = 0; ix < num_keys; ix++) { @@ -192,7 +192,7 @@ void insert_into_and_scan_btree(int num_keys) } { - auto heap = SQL::Heap::construct("test.db"); + auto heap = SQL::Heap::construct("/tmp/test.db"); auto btree = setup_btree(heap); int count = 0; diff --git a/Tests/LibSQL/TestSqlDatabase.cpp b/Tests/LibSQL/TestSqlDatabase.cpp index de02a75857..ee65436af6 100644 --- a/Tests/LibSQL/TestSqlDatabase.cpp +++ b/Tests/LibSQL/TestSqlDatabase.cpp @@ -78,55 +78,55 @@ void verify_table_contents(SQL::Database& db, int expected_count) void insert_and_verify(int count) { - ScopeGuard guard([]() { unlink("test.db"); }); + ScopeGuard guard([]() { unlink("/tmp/test.db"); }); { - auto db = SQL::Database::construct("test.db"); + auto db = SQL::Database::construct("/tmp/test.db"); setup_table(db); db->commit(); } { - auto db = SQL::Database::construct("test.db"); + auto db = SQL::Database::construct("/tmp/test.db"); insert_into_table(db, count); db->commit(); } { - auto db = SQL::Database::construct("test.db"); + auto db = SQL::Database::construct("/tmp/test.db"); verify_table_contents(db, count); } } TEST_CASE(create_heap) { - ScopeGuard guard([]() { unlink("test.db"); }); - auto heap = SQL::Heap::construct("test.db"); + ScopeGuard guard([]() { unlink("/tmp/test.db"); }); + auto heap = SQL::Heap::construct("/tmp/test.db"); EXPECT_EQ(heap->version(), 0x00000001u); } TEST_CASE(create_database) { - ScopeGuard guard([]() { unlink("test.db"); }); - auto db = SQL::Database::construct("test.db"); + ScopeGuard guard([]() { unlink("/tmp/test.db"); }); + auto db = SQL::Database::construct("/tmp/test.db"); db->commit(); } TEST_CASE(add_schema_to_database) { - ScopeGuard guard([]() { unlink("test.db"); }); - auto db = SQL::Database::construct("test.db"); + ScopeGuard guard([]() { unlink("/tmp/test.db"); }); + auto db = SQL::Database::construct("/tmp/test.db"); setup_schema(db); db->commit(); } TEST_CASE(get_schema_from_database) { - ScopeGuard guard([]() { unlink("test.db"); }); + ScopeGuard guard([]() { unlink("/tmp/test.db"); }); { - auto db = SQL::Database::construct("test.db"); + auto db = SQL::Database::construct("/tmp/test.db"); setup_schema(db); db->commit(); } { - auto db = SQL::Database::construct("test.db"); + auto db = SQL::Database::construct("/tmp/test.db"); auto schema = db->get_schema("TestSchema"); EXPECT(schema); } @@ -134,22 +134,22 @@ TEST_CASE(get_schema_from_database) TEST_CASE(add_table_to_database) { - ScopeGuard guard([]() { unlink("test.db"); }); - auto db = SQL::Database::construct("test.db"); + ScopeGuard guard([]() { unlink("/tmp/test.db"); }); + auto db = SQL::Database::construct("/tmp/test.db"); setup_table(db); db->commit(); } TEST_CASE(get_table_from_database) { - ScopeGuard guard([]() { unlink("test.db"); }); + ScopeGuard guard([]() { unlink("/tmp/test.db"); }); { - auto db = SQL::Database::construct("test.db"); + auto db = SQL::Database::construct("/tmp/test.db"); setup_table(db); db->commit(); } { - auto db = SQL::Database::construct("test.db"); + auto db = SQL::Database::construct("/tmp/test.db"); auto table = db->get_table("TestSchema", "TestTable"); EXPECT(table); EXPECT_EQ(table->name(), "TestTable"); diff --git a/Tests/LibSQL/TestSqlHashIndex.cpp b/Tests/LibSQL/TestSqlHashIndex.cpp index e1878569a5..c6f0b5badc 100644 --- a/Tests/LibSQL/TestSqlHashIndex.cpp +++ b/Tests/LibSQL/TestSqlHashIndex.cpp @@ -138,9 +138,9 @@ NonnullRefPtr<SQL::HashIndex> setup_hash_index(SQL::Heap& heap) void insert_and_get_to_and_from_hash_index(int num_keys) { - ScopeGuard guard([]() { unlink("test.db"); }); + ScopeGuard guard([]() { unlink("/tmp/test.db"); }); { - auto heap = SQL::Heap::construct("test.db"); + auto heap = SQL::Heap::construct("/tmp/test.db"); auto hash_index = setup_hash_index(heap); for (auto ix = 0; ix < num_keys; ix++) { @@ -156,7 +156,7 @@ void insert_and_get_to_and_from_hash_index(int num_keys) } { - auto heap = SQL::Heap::construct("test.db"); + auto heap = SQL::Heap::construct("/tmp/test.db"); auto hash_index = setup_hash_index(heap); for (auto ix = 0; ix < num_keys; ix++) { @@ -232,9 +232,9 @@ TEST_CASE(hash_index_50_keys) void insert_into_and_scan_hash_index(int num_keys) { - ScopeGuard guard([]() { unlink("test.db"); }); + ScopeGuard guard([]() { unlink("/tmp/test.db"); }); { - auto heap = SQL::Heap::construct("test.db"); + auto heap = SQL::Heap::construct("/tmp/test.db"); auto hash_index = setup_hash_index(heap); for (auto ix = 0; ix < num_keys; ix++) { @@ -250,7 +250,7 @@ void insert_into_and_scan_hash_index(int num_keys) } { - auto heap = SQL::Heap::construct("test.db"); + auto heap = SQL::Heap::construct("/tmp/test.db"); auto hash_index = setup_hash_index(heap); Vector<bool> found; for (auto ix = 0; ix < num_keys; ix++) { |