mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-29 10:43:43 +01:00
SQLite3 persistence test: Don't leave file in CWD
This commit is contained in:
parent
f7bb444f78
commit
5b9cfa16a1
12
test.lua
12
test.lua
@ -424,7 +424,8 @@ test_logfile(false)
|
|||||||
-- SQLite3
|
-- SQLite3
|
||||||
do
|
do
|
||||||
local sqlite3 = persistence.sqlite3()
|
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:init()
|
||||||
p:rewrite()
|
p:rewrite()
|
||||||
p:set_root("key", "value")
|
p:set_root("key", "value")
|
||||||
@ -447,7 +448,7 @@ do
|
|||||||
p:collectgarbage()
|
p:collectgarbage()
|
||||||
p:defragment_ids()
|
p:defragment_ids()
|
||||||
local rows = {}
|
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)
|
_G.table.insert(rows, row)
|
||||||
end
|
end
|
||||||
assert(modlib.table.equals(rows, {
|
assert(modlib.table.equals(rows, {
|
||||||
@ -455,16 +456,17 @@ do
|
|||||||
{ 1, 3, "other key", 3, "other value" },
|
{ 1, 3, "other key", 3, "other value" },
|
||||||
{ 2, 3, "a", 2, 1 },
|
{ 2, 3, "a", 2, 1 },
|
||||||
{ 2, 3, "b", 2, 2 },
|
{ 2, 3, "b", 2, 2 },
|
||||||
{2, 3, "c", 2, 3}
|
{ 2, 3, "c", 2, 3 },
|
||||||
}))
|
}))
|
||||||
p:close()
|
p:close()
|
||||||
p = sqlite3.new("database.test.sqlite3", {})
|
p = sqlite3.new(path, {})
|
||||||
p:init()
|
p:init()
|
||||||
assert(modlib.table.equals(p.root, {
|
assert(modlib.table.equals(p.root, {
|
||||||
key = { a = 1, b = 2, c = 3 },
|
key = { a = 1, b = 2, c = 3 },
|
||||||
["other key"] = "other value"
|
["other key"] = "other value",
|
||||||
}))
|
}))
|
||||||
p:close()
|
p:close()
|
||||||
|
os.remove(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- in-game tests & b3d testing
|
-- in-game tests & b3d testing
|
||||||
|
Loading…
Reference in New Issue
Block a user