diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..a105ff1 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,33 @@ +name: Tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e ".[dev]" + + - name: Run linter + run: make lint + + - name: Run tests + run: pytest diff --git a/src/jsonldb/database.py b/src/jsonldb/database.py index 2d5030f..51762f0 100644 --- a/src/jsonldb/database.py +++ b/src/jsonldb/database.py @@ -68,10 +68,10 @@ def _get_from_wal(self, record_id: str) -> Record | None: for entry in self.wal.scan(): if entry.record_id == record_id: last_entry = entry - + if last_entry is None: return None - + if last_entry.op == "delete": return None if last_entry.op in ("insert", "update") and last_entry.data: @@ -141,7 +141,7 @@ def count(self) -> int: def compact(self) -> int: compacted_records = {} - + for record in self._scan_data(): compacted_records[record.id] = record