Page MenuHomeSoftware Heritage

D6283.diff
No OneTemporary

D6283.diff

diff --git a/swh/storage/postgresql/storage.py b/swh/storage/postgresql/storage.py
--- a/swh/storage/postgresql/storage.py
+++ b/swh/storage/postgresql/storage.py
@@ -953,12 +953,9 @@
zip(db.snapshot_get_cols, fetched_branches[branches_count])
)["name"]
- if branches:
- return PartialBranches(
- id=snapshot_id, branches=branches, next_branch=next_branch,
- )
-
- return None
+ return PartialBranches(
+ id=snapshot_id, branches=branches, next_branch=next_branch,
+ )
@timed
@db_transaction()
diff --git a/swh/storage/tests/storage_tests.py b/swh/storage/tests/storage_tests.py
--- a/swh/storage/tests/storage_tests.py
+++ b/swh/storage/tests/storage_tests.py
@@ -3639,6 +3639,23 @@
assert sorted(branches) == sorted(expected_branches)
assert partial_branches["next_branch"] is None
+ def test_snapshot_get_branches_from_no_result(self, swh_storage, sample_data):
+ snapshot = Snapshot(
+ branches={
+ b"refs/heads/master": SnapshotBranch(
+ target=sample_data.revision.id, target_type=TargetType.REVISION,
+ ),
+ },
+ )
+ swh_storage.snapshot_add([snapshot])
+
+ partial_branches = swh_storage.snapshot_get_branches(
+ snapshot.id, branches_from=b"s",
+ )
+
+ assert partial_branches is not None
+ assert partial_branches["branches"] == {}
+
def test_snapshot_add_get(self, swh_storage, sample_data):
snapshot = sample_data.snapshot
origin = sample_data.origin

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 3, 5:31 PM (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3224423

Event Timeline