Skip to content

Commit

Permalink
Enable read only DB tests on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminwinger committed Sep 6, 2024
1 parent d18721d commit 18b92c0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 26 deletions.
4 changes: 0 additions & 4 deletions test/c_api/database_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ TEST_F(CApiDatabaseTest, CreationAndDestroy) {
}

TEST_F(CApiDatabaseTest, CreationReadOnly) {
// TODO: Enable this test on Windows when the read-only mode is implemented.
#ifdef _WIN32
return;
#endif
kuzu_database database;
kuzu_connection connection;
kuzu_query_result queryResult;
Expand Down
8 changes: 1 addition & 7 deletions tools/nodejs_api/test/test_database.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ describe("Database constructor", function () {
});

it("should create a database in read-only mode", async function () {
// TODO: Enable this test on Windows when the read-only mode is implemented.
if (process.platform === "win32") {
this._runnable.title += " (skipped: not implemented on Windows)";
this.skip();
}

const tmpDbPath = await new Promise((resolve, reject) => {
tmp.dir({ unsafeCleanup: true }, (err, path, _) => {
if (err) {
Expand Down Expand Up @@ -193,7 +187,7 @@ describe("Database constructor", function () {
it("should create an in-memory database when no path is provided", async function () {
const testDb = new kuzu.Database();
const conn = new kuzu.Connection(testDb);
let res = await conn.query("CREATE NODE TABLE person(name STRING, age INT64, PRIMARY KEY(name));");
let res = await conn.query("CREATE NODE TABLE person(name STRING, age INT64, PRIMARY KEY(name));");
res.close();
res = await conn.query("CREATE (:person {name: 'Alice', age: 30});");
res.close();
Expand Down
6 changes: 1 addition & 5 deletions tools/python_api/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,7 @@ def conn_db_readonly(tmp_path: Path) -> ConnDB:
"""Return a cached read-only connection and database."""
global _READONLY_CONN_DB_
if _READONLY_CONN_DB_ is None:
# On Windows, the read-only mode is not implemented yet.
# Therefore, we create a writable database on Windows.
# However, the caller should ensure that the database is not modified.
# TODO: Remove this workaround when the read-only mode is implemented on Windows.
_READONLY_CONN_DB_ = _create_conn_db(tmp_path, read_only=sys.platform != "win32")
_READONLY_CONN_DB_ = _create_conn_db(tmp_path, read_only=True)
return _READONLY_CONN_DB_


Expand Down
12 changes: 5 additions & 7 deletions tools/python_api/test/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@ def test_database_close(tmp_path: Path, build_dir: Path) -> None:
assert db._database is not None

# Open the database on a subprocess. It should raise an exception.
# TODO: Enable this test on Windows when the read-only mode is implemented.
if sys.platform != "win32":
with pytest.raises(
RuntimeError,
match=r"RuntimeError: IO exception: Could not set lock on file",
):
open_database_on_subprocess(db_path, build_dir)
with pytest.raises(
Exception,
match=r"RuntimeError: IO exception: Could not set lock on file",
):
open_database_on_subprocess(db_path, build_dir)

db.close()
assert db.is_closed
Expand Down
3 changes: 0 additions & 3 deletions tools/python_api/test/test_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ def test_db_path_exception() -> None:


def test_read_only_exception(conn_db_readonly: ConnDB) -> None:
# TODO: Enable this test on Windows when the read-only mode is implemented.
if sys.platform == "win32":
pytest.skip("Read-only mode has not been implemented on Windows yet")
_, db = conn_db_readonly
path = db.database_path
read_only_db = kuzu.Database(path, read_only=True)
Expand Down

0 comments on commit 18b92c0

Please sign in to comment.