From d0285a21571d0ed2df14ff5edac4a263eaaabcae Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 7 Mar 2023 00:01:16 +0300 Subject: [PATCH] Fix #3 Errors with Slice Out of bounds Error when Retrieving Value that is an empty string --- CHANGELOG.md | 10 ++++++++++ Cargo.lock | 6 +++--- Cargo.toml | 4 ++-- test/test_async_py_scdb.py | 12 ++++++++++++ test/test_py_scdb.py | 11 +++++++++++ 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa37b79..a599b3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [0.2.2] - 2023-03-06 + +### Added + +### Changed + +### Fixed + +- Fixed Slice Out of bounds Error when Retrieving Value that is an empty string. + ## [0.2.1] - 2023-02-28 ### Added diff --git a/Cargo.lock b/Cargo.lock index cd17b14..93714ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -643,7 +643,7 @@ dependencies = [ [[package]] name = "py_scdb" -version = "0.2.0" +version = "0.2.2" dependencies = [ "async-std", "pyo3", @@ -786,9 +786,9 @@ dependencies = [ [[package]] name = "scdb" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bceeadc4e5c75bd27b3825e34b93c0e1633b739a7ed7ffff5e0e604e0600ad0" +checksum = "6acc81dd109772f5e3f5dadc6c029896e90e2409f2a792a79d044dbdd0534146" dependencies = [ "clokwerk", "libc", diff --git a/Cargo.toml b/Cargo.toml index 73a86dd..ff0f1b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "py_scdb" -version = "0.2.0" +version = "0.2.2" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -10,6 +10,6 @@ crate-type = ["cdylib"] [dependencies] pyo3 = { version = "0.17", features = ["extension-module"] } -scdb = "0.2" +scdb = "0.2.1" pyo3-asyncio = { version = "0.17", features = ["attributes", "async-std-runtime"] } async-std = "1.12" diff --git a/test/test_async_py_scdb.py b/test/test_async_py_scdb.py index ace2d35..c0dc644 100644 --- a/test/test_async_py_scdb.py +++ b/test/test_async_py_scdb.py @@ -92,6 +92,18 @@ async def test_get_existing_key(store: AsyncStore): assert (await store.get(k=k)) == v +@pytest.mark.asyncio +@pytest.mark.parametrize("store", async_store_fixture) +async def test_get_value_that_si_empty_string(store: AsyncStore): + """Does not error with out of bounds when the value is an empty string thanks to scdb v0.2.1""" + key = "foo" + value = "" + + await fill_async_store(store=store, data=[(key, value)]) + for _ in range(2): + assert (await store.get(k=key)) == value + + @pytest.mark.asyncio @pytest.mark.parametrize("store", async_store_fixture) async def test_get_non_existing_key(store: AsyncStore): diff --git a/test/test_py_scdb.py b/test/test_py_scdb.py index 91e21e5..309fff5 100644 --- a/test/test_py_scdb.py +++ b/test/test_py_scdb.py @@ -67,6 +67,17 @@ def test_get_existing_key(store: Store): assert store.get(k=k) == v +@pytest.mark.parametrize("store", store_fixture) +def test_get_value_that_is_empty_string(store: Store): + """Does not error with out of bounds when the value is an empty string thanks to scdb v0.2.1""" + key = "foo" + value = "" + + fill_store(store=store, data=[(key, value)]) + for _ in range(3): + assert store.get(k=key) == value + + @pytest.mark.parametrize("store", store_fixture) def test_search_disabled(store: Store): """Raises exception when a search-disabled store's search method is called"""