Skip to content

Commit

Permalink
Add tests for uncommitted changes in transaction warning
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmynter committed Feb 21, 2024
1 parent 8cdb26e commit b139cdb
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,33 @@ def test_transaction_bad_repo(fs: LakeFSFileSystem) -> None:
with pytest.raises(ValueError, match="repository .* does not exist"):
with fs.transaction(repository="REEEE"):
pass


def test_warn_uncommitted_changes(
random_file_factory: RandomFileFactory,
fs: LakeFSFileSystem,
repository: Repository,
temp_branch: Branch,
) -> None:
random_file = random_file_factory.make()

lpath = str(random_file)

with pytest.warns(match="uncommitted changes.*lost"):
with fs.transaction(repository, temp_branch) as tx:
fs.put_file(lpath, f"{repository.id}/{tx.branch.id}/{random_file.name}")


def test_warn_uncommitted_changes_on_persisted_branch(
random_file_factory: RandomFileFactory,
fs: LakeFSFileSystem,
repository: Repository,
temp_branch: Branch,
) -> None:
random_file = random_file_factory.make()

lpath = str(random_file)

with pytest.warns(match="uncommitted changes(?:(?!lost).)*$"):
with fs.transaction(repository, temp_branch, delete="never") as tx:
fs.put_file(lpath, f"{repository.id}/{tx.branch.id}/{random_file.name}")

0 comments on commit b139cdb

Please sign in to comment.