Skip to content

Add basic test for rsynchl importer#79

Open
hiijoshi wants to merge 2 commits intoborgbackup:masterfrom
hiijoshi:add-rsynchl-test
Open

Add basic test for rsynchl importer#79
hiijoshi wants to merge 2 commits intoborgbackup:masterfrom
hiijoshi:add-rsynchl-test

Conversation

@hiijoshi
Copy link

@hiijoshi hiijoshi commented Mar 21, 2026

Summary

Added a basic test for the rsynchl importer.

Changes

  • Added a test that simulates rsync-style backup folders
  • Verifies archives are created in the target repository
  • Improves test coverage for importer behavior

Reason

This helps validate rsynchl import functionality and improves confidence in importer behavior.
This test follows the existing integration-style approach used in test_borg and extends coverage to another importer.

Copy link
Member

@ThomasWaldmann ThomasWaldmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR, some stuff i found.


# Create archives in the source repository
subprocess.check_call(["borg", "create", f"{source_repo}::archive1", "."], cwd=str(archive1_data))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to avoid changing unrelated files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_borg is for the "from borg" importer.

assert extract_dir2.join("file2.txt").read() == "This is file 2 in archive 2"


def test_rsynchl_import(tmpdir, monkeypatch):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be rather in a test_rsync(hl?) module.

Comment on lines +68 to +69
archive1.join("file.txt").write("hello1")
archive2.join("file.txt").write("hello2")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe have 2 files in each archive.

Comment on lines +85 to +86
assert len(archives) >= 1
assert any("backup1" in a or "backup2" in a for a in archives) No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather do the tests in the same way as in test_borg. that is simpler and more correct (you needed "all" here, not "any").

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, do not only check the archives, but also the files in the archives - see test_borg.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always end files with a linefeed so that diff does not complain.

@hiijoshi
Copy link
Author

hiijoshi commented Mar 21, 2026

Thanks for the review!

I understand the issue now. I’ll update this PR by:

  • moving the rsynchl test into a separate test module
  • avoiding unrelated file changes
  • adding two files in each backup
  • verifying both imported archives
  • extracting the archives and checking file contents, similar to test_borg
  • fixing the missing newline at end of file

I’ll push an updated version shortly.

@hiijoshi
Copy link
Author

Thanks for the detailed feedback!

I’ve addressed the issues:

  • Split importer tests into separate modules (test_rsynchl.py, test_tmbackup.py)
  • Removed unrelated code from test_borg.py
  • Strengthened assertions to verify archive names and extracted contents
  • Ensured proper formatting and structure

All tests are now passing.

Please let me know if anything else should be improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants