Skip to content

Commit

Permalink
Fix #3 Errors with Slice Out of bounds Error when Retrieving Value th…
Browse files Browse the repository at this point in the history
…at is an empty string
  • Loading branch information
Tinitto committed Mar 6, 2023
1 parent 63e9722 commit d0285a2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
12 changes: 12 additions & 0 deletions test/test_async_py_scdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
11 changes: 11 additions & 0 deletions test/test_py_scdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit d0285a2

Please sign in to comment.