Skip to content

testsuite: add Archives and LegacyArchives unit tests, refs #9556#9648

Merged
ThomasWaldmann merged 3 commits into
borgbackup:masterfrom
mr-raj12:testsuite-legacy-archives
May 22, 2026
Merged

testsuite: add Archives and LegacyArchives unit tests, refs #9556#9648
ThomasWaldmann merged 3 commits into
borgbackup:masterfrom
mr-raj12:testsuite-legacy-archives

Conversation

@mr-raj12
Copy link
Copy Markdown
Contributor

@mr-raj12 mr-raj12 commented May 15, 2026

Description

Adds unit tests for Archives and LegacyArchives, refs #9556.

Phase 3 (#9644) merged without test coverage for the new Archives-only code paths and without any tests for LegacyArchives. This PR adds both.

src/borg/testsuite/archives_test.py — 70+ tests for Archives (Borg 2.x, manifest.py):

  • init, raw-dict round-trip (_set_raw_dict / _get_raw_dict)
  • ids, count, names, exists, exists_id, exists_name_and_id, exists_name_and_ts
  • create (str ts, datetime ts, duplicate guard, overwrite=True)
  • get / get_by_id (happy path, missing → None, raw=True)
  • delete_by_id, undelete_by_id, nuke_by_id
  • _get_archive_meta (ObjectNotFound path, success path, bad version)
  • list() — sort, reverse, first/last pagination, date filters (older/newer/oldest/newest), all match prefixes (name:, user:, host:, tags:, aid:, ambiguous aid:)
  • get_one (exact match, zero matches, multiple matches)
  • list_considering (name-conflict guard, full delegation)
  • regression: _matching_info_tuples must materialise _info_tuples() via list() before returning — if removed, the raw generator reaches .sort() and raises AttributeError

src/borg/testsuite/legacy_archives_test.py — 50+ tests for LegacyArchives (legacy/archives.py), same coverage plus:

  • prepare / finish round-trip
  • NotImplementedError stubs (exists_id, exists_name_and_id, exists_name_and_ts, delete_by_id, undelete_by_id, nuke_by_id)
  • protocol check: isinstance(la, ArchivesInterface)
  • integration smoke: Manifest picks LegacyArchives for a LegacyRepository

No production code changes.

Refs #9556

Checklist

  • PR is against master
  • New code has tests (this PR is the tests)
  • Tests pass
  • Commit message references related issue

@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.81%. Comparing base (6659bd9) to head (6cb6ac4).
⚠️ Report is 37 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9648      +/-   ##
==========================================
+ Coverage   83.08%   83.81%   +0.72%     
==========================================
  Files          90       90              
  Lines       15653    15667      +14     
  Branches     2356     2359       +3     
==========================================
+ Hits        13006    13131     +125     
+ Misses       1887     1794      -93     
+ Partials      760      742      -18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mr-raj12 mr-raj12 force-pushed the testsuite-legacy-archives branch from ca6ff9b to dad3f58 Compare May 16, 2026 01:53
Copy link
Copy Markdown
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.

some minor renames for better readability please, in both files.

Comment thread src/borg/testsuite/archives_test.py Outdated
Comment thread src/borg/testsuite/archives_test.py Outdated
Comment thread src/borg/testsuite/archives_test.py Outdated
@mr-raj12 mr-raj12 requested a review from ThomasWaldmann May 22, 2026 12:09
Copy link
Copy Markdown
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.

LGTM.

@ThomasWaldmann ThomasWaldmann merged commit 614baf5 into borgbackup:master May 22, 2026
20 checks passed
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