SQLite3 persistence test: Don't leave file in CWD

This commit is contained in:
Lars Mueller 2022-01-23 13:53:15 +01:00
parent f7bb444f78
commit 5b9cfa16a1

@ -424,7 +424,8 @@ test_logfile(false)
-- SQLite3
do
local sqlite3 = persistence.sqlite3()
local p = sqlite3.new("database.test.sqlite3", {})
local path = modlib.mod.get_resource("modlib", "database.test.sqlite3")
local p = sqlite3.new(path, {})
p:init()
p:rewrite()
p:set_root("key", "value")
@ -447,7 +448,7 @@ do
p:collectgarbage()
p:defragment_ids()
local rows = {}
for row in p.database:rows"SELECT * FROM table_entries ORDER BY table_id, key_type, key" do
for row in p.database:rows("SELECT * FROM table_entries ORDER BY table_id, key_type, key") do
_G.table.insert(rows, row)
end
assert(modlib.table.equals(rows, {
@ -455,16 +456,17 @@ do
{ 1, 3, "other key", 3, "other value" },
{ 2, 3, "a", 2, 1 },
{ 2, 3, "b", 2, 2 },
{2, 3, "c", 2, 3}
{ 2, 3, "c", 2, 3 },
}))
p:close()
p = sqlite3.new("database.test.sqlite3", {})
p = sqlite3.new(path, {})
p:init()
assert(modlib.table.equals(p.root, {
key = { a = 1, b = 2, c = 3 },
["other key"] = "other value"
["other key"] = "other value",
}))
p:close()
os.remove(path)
end
-- in-game tests & b3d testing