ostree: add convenience function for using default OSTree deployment
This adds a `default: true` option for all cases where OSTree information is specified in schemas and allows for the information to be picked up from the filesystem. This is a safe operation because when building disk images there is no known case where having two deployments makes sense. In the case there ever were a case then the osname, ref, and serial options still exist and can be used. Co-authored-by: Luke Yang <luyang@redhat.com> Co-authored-by: Michael Vogt <michael.vogt@gmail.com>
This commit is contained in:
parent
2021b915f1
commit
e1cbf92673
11 changed files with 264 additions and 49 deletions
|
|
@ -11,6 +11,7 @@ import unittest
|
|||
|
||||
import pytest
|
||||
|
||||
from osbuild.testutil import make_fake_tree
|
||||
from osbuild.util import ostree
|
||||
|
||||
from .. import test
|
||||
|
|
@ -208,3 +209,41 @@ class TestPasswdLike(unittest.TestCase):
|
|||
check.read_from(file)
|
||||
|
||||
assert subids.db == check.db
|
||||
|
||||
|
||||
def test_parse_default_deployment_happy(tmp_path):
|
||||
deployment = {
|
||||
"default": True,
|
||||
}
|
||||
make_fake_tree(tmp_path, {
|
||||
"ostree/deploy/fedora-coreos/deploy/72f807.0": "",
|
||||
})
|
||||
osname, ref, serial = ostree.parse_deployment_option(tmp_path, deployment)
|
||||
assert osname == "fedora-coreos"
|
||||
assert ref == "72f807"
|
||||
assert serial == "0"
|
||||
|
||||
|
||||
def test_parse_default_deployment_sad(tmp_path):
|
||||
deployment = {
|
||||
"default": True,
|
||||
}
|
||||
make_fake_tree(tmp_path, {
|
||||
"ostree/deploy/fedora-coreos/deploy/72f807.0": "",
|
||||
"ostree/deploy/fedora-coreos/deploy/123456.0": "",
|
||||
})
|
||||
with pytest.raises(ValueError) as exp:
|
||||
ostree.parse_deployment_option(tmp_path, deployment)
|
||||
assert "More than one deployment found: [" in str(exp.value)
|
||||
|
||||
|
||||
def test_parse_deployment_happy(tmp_path):
|
||||
deployment = {
|
||||
"osname": "fedora-coreos",
|
||||
"ref": "some-ref",
|
||||
"serial": "0",
|
||||
}
|
||||
osname, ref, serial = ostree.parse_deployment_option(tmp_path, deployment)
|
||||
assert osname == "fedora-coreos"
|
||||
assert ref == "some-ref"
|
||||
assert serial == "0"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue