Skip to content

Commit

Permalink
Merge pull request #456 from citrus-it/origindep
Browse files Browse the repository at this point in the history
Add test for an origin dependency
  • Loading branch information
hadfl authored Oct 23, 2023
2 parents ce33a10 + b60e67b commit 3456a33
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions src/tests/api/t_pkg_api_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,29 @@ class TestPkgApiInstall(pkg5unittest.SingleDepotTestCase):
add file tmp/motd mode=0644 owner=root group=bin path=etc/motd
close"""

barge10 = """
open [email protected],5.11-0
add file tmp/cat mode=0555 owner=root group=bin path=/bin/cat
add file tmp/motd mode=0444 owner=root group=bin path=etc/motd
close """

derelict = """
open [email protected],5.11-0
add file tmp/motd mode=0444 owner=root group=bin path=etc/motd
close """

barge11 = """
open [email protected],5.11-0
add file tmp/cat mode=0555 owner=root group=bin path=/bin/cat
add depend type=require fmri=pkg:/derelict
close """

barge12 = """
open [email protected],5.11-0
add file tmp/cat mode=0555 owner=root group=bin path=/bin/cat
add depend type=origin fmri=pkg:/[email protected]
close """

misc_files = ["tmp/libc.so.1", "tmp/cat", "tmp/baz", "tmp/motd"]

def setUp(self):
Expand Down Expand Up @@ -492,6 +515,66 @@ def test_update_backwards(self):
self.__do_update(api_obj, ["carriage", "horse@1"])
self.pkg("list carriage@3 horse@1")

def test_origin_depend(self):
"""Confirm that an origin dependency causes the proper sequence of
upgrades to occur."""

self.pkgsend_bulk(self.rurl, self.barge10)
api_obj = self.image_create(self.rurl)

self.__do_install(api_obj, ["barge"])

self.pkg("list barge derelict", exit=3)

# Attempting to update barge should result in nothing to do.
api_obj.reset()
for pd in api_obj.gen_plan_update(["barge"]):
continue
self.assertTrue(api_obj.planned_nothingtodo())

# Publish derelict and barge versions 1.1 and 1.2
self.pkgsend_bulk(
self.rurl, (self.barge11, self.barge12, self.derelict)
)

# It should not be possible to update directly to [email protected] due to
# its origin dependency.
api_obj.reset()
self.assertRaises(
api_errors.PlanCreationException,
lambda *args, **kwargs: list(
api_obj.gen_plan_update(*args, **kwargs)
),
["[email protected]"],
)

# Upgrading barge should result in derelict being installed, and barge
# only going to version 1.1
api_obj.reset()
self.__do_update(api_obj, ["barge"])
self.pkg("list [email protected] derelict")

# It should not be possible to uninstall derelict at this point as it
# is required by [email protected]
api_obj.reset()
self.assertRaises(
api_errors.NonLeafPackageException,
lambda *args, **kwargs: list(
api_obj.gen_plan_uninstall(*args, **kwargs)
),
["derelict"],
)

# A subsequent update of barge should move it to 1.2
api_obj.reset()
self.__do_update(api_obj, ["barge"])
self.pkg("list [email protected] derelict")

# And now derelict should be uninstallable
api_obj.reset()
self.__do_uninstall(api_obj, ["derelict"])
self.pkg("list derelict", exit=1)

def test_multi_publisher(self):
"""Verify that package install works as expected when multiple
publishers share the same repository."""
Expand Down

0 comments on commit 3456a33

Please sign in to comment.