diff options
author | Petr Vaněk <arkamar@atlas.cz> | 2022-11-07 09:25:40 +0100 |
---|---|---|
committer | Petr Vaněk <arkamar@atlas.cz> | 2022-11-07 12:36:27 +0100 |
commit | 78936996d6669561a9ac8c750ec78486b6b8f91b (patch) | |
tree | 0c8e2c4fe985a002e29f2220a387ddb910b63d4b /test/lua | |
parent | 3c993db821ffa5ef5f251e15bda9da1307e618a2 (diff) | |
download | rspamd-78936996d6669561a9ac8c750ec78486b6b8f91b.tar.gz rspamd-78936996d6669561a9ac8c750ec78486b6b8f91b.zip |
[Test] Do not use hardcoded path for sqlite3 tests
Diffstat (limited to 'test/lua')
-rw-r--r-- | test/lua/unit/sqlite3.lua | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/test/lua/unit/sqlite3.lua b/test/lua/unit/sqlite3.lua index 15dc3d3fb..c431258e7 100644 --- a/test/lua/unit/sqlite3.lua +++ b/test/lua/unit/sqlite3.lua @@ -1,18 +1,19 @@ context("Sqlite3 API", function() local sqlite3 = require "rspamd_sqlite3" + local tmpdir = os.getenv("TMPDIR") or "/tmp" test("Sqlite3 open", function() - os.remove('/tmp/rspamd_unit_test_sqlite3.sqlite') - local db = sqlite3.open('/tmp/rspamd_unit_test_sqlite3.sqlite') + os.remove(tmpdir .. '/rspamd_unit_test_sqlite3.sqlite') + local db = sqlite3.open(tmpdir .. '/rspamd_unit_test_sqlite3.sqlite') assert_not_nil(db, "should be able to create sqlite3 db") db = sqlite3.open('/non/existent/path/rspamd_unit_test_sqlite3.sqlite') assert_nil(db, "should not be able to create sqlite3 db") - os.remove('/tmp/rspamd_unit_test_sqlite3.sqlite') + os.remove(tmpdir .. '/rspamd_unit_test_sqlite3.sqlite') end) test("Sqlite3 query", function() - os.remove('/tmp/rspamd_unit_test_sqlite3-1.sqlite') - local db = sqlite3.open('/tmp/rspamd_unit_test_sqlite3-1.sqlite') + os.remove(tmpdir .. '/rspamd_unit_test_sqlite3-1.sqlite') + local db = sqlite3.open(tmpdir .. '/rspamd_unit_test_sqlite3-1.sqlite') assert_not_nil(db, "should be able to create sqlite3 db") local ret = db:sql([[ @@ -23,12 +24,12 @@ context("Sqlite3 API", function() INSERT INTO x VALUES (?1, ?2); ]], 1, 'test') assert_true(ret, "should be able to insert row") - os.remove('/tmp/rspamd_unit_test_sqlite3-1.sqlite') + os.remove(tmpdir .. '/rspamd_unit_test_sqlite3-1.sqlite') end) test("Sqlite3 rows", function() - os.remove('/tmp/rspamd_unit_test_sqlite3-2.sqlite') - local db = sqlite3.open('/tmp/rspamd_unit_test_sqlite3-2.sqlite') + os.remove(tmpdir .. '/rspamd_unit_test_sqlite3-2.sqlite') + local db = sqlite3.open(tmpdir .. '/rspamd_unit_test_sqlite3-2.sqlite') assert_not_nil(db, "should be able to create sqlite3 db") local ret = db:sql([[ @@ -44,6 +45,6 @@ context("Sqlite3 API", function() assert_equal(row.id, '1') assert_equal(row.value, 'test') end - os.remove('/tmp/rspamd_unit_test_sqlite3-2.sqlite') + os.remove(tmpdir .. '/rspamd_unit_test_sqlite3-2.sqlite') end) end)
\ No newline at end of file |