Skip to content

Commit

Permalink
test: Add a test updating a publish with bad history
Browse files Browse the repository at this point in the history
  • Loading branch information
Melkor333 committed Nov 7, 2024
1 parent 7340ac1 commit f8a3654
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
43 changes: 43 additions & 0 deletions pyaptly/tests/publish-bad.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[[publish.fakerepo01]]
gpg-key = "6D79A810B9B7ABAE"
skip-contents = true
automatic-update = true
components = "main"
distribution = "main"
snapshots = [
{ name = "fakerepo02-%T", timestamp = "current", archive-on-update = "archived-fakerepo01-%T" },
]

[[publish.fakerepo02]]
gpg-key = "6D79A810B9B7ABAE"
automatic-update = true
components = "main"
distribution = "main"
snapshots = [
{ name = "fakerepo01-%T", timestamp = "current", archive-on-update = "archived-fakerepo02-%T" },
]

[mirror.fakerepo01]
max-tries = 2
archive = "http://localhost:3123/fakerepo01"
gpg-keys = [
"2841988729C7F3FF",
]
components = "main"
distribution = "main"

[mirror.fakerepo02]
archive = "http://localhost:3123/fakerepo02"
gpg-keys = [
"2841988729C7F3FF",
]
components = "main"
distribution = "main"

[snapshot."fakerepo01-%T"]
mirror = "fakerepo01"
timestamp = { time = "00:00" }

[snapshot."fakerepo02-%T"]
mirror = "fakerepo02"
timestamp = { time = "00:00", repeat-weekly = "sat" }
25 changes: 25 additions & 0 deletions pyaptly/tests/test_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,28 @@ def test_repo_create_single(config, repo, test_key_03):
main.main(args)
state = state_reader.SystemStateReader()
assert set(["centrify"]) == state.repos()


@pytest.mark.parametrize("config", ["publish.toml"], indirect=True)
def test_publish_update_wrong_snapshots(config, publish_create, freeze):
"""Test if updating publishes works when the snapshot history is wrong."""
freeze.move_to("2012-10-11 10:10:10")
args = ["-c", config, "snapshot", "create"]
main.main(args)
args = ["-c", config.replace('.toml','-bad.toml'), "publish", "update"]
main.main(args)
state = state_reader.SystemStateReader()
expect = set(
[
"fakerepo01-20121011T0000Z",
"fakerepo02-20121006T0000Z",
"fakerepo01-20121010T0000Z",
]
)
assert expect == state.snapshots()
# Reversed!
expect2 = {
"fakerepo01 main": set(["fakerepo02-20121006T0000Z"]),
"fakerepo02 main": set(["fakerepo01-20121011T0000Z"]),
}
assert expect2 == state.publish_map()

0 comments on commit f8a3654

Please sign in to comment.