osbuild: take partition into account in calc_id and add test
This commit is contained in:
parent
9cf68394d9
commit
e76e0e92d6
2 changed files with 24 additions and 0 deletions
|
|
@ -37,6 +37,8 @@ class Mount:
|
|||
m.update(json.dumps(self.info.name, sort_keys=True).encode())
|
||||
if self.device:
|
||||
m.update(json.dumps(self.device.id, sort_keys=True).encode())
|
||||
if self.partition:
|
||||
m.update(json.dumps(self.partition, sort_keys=True).encode())
|
||||
if self.target:
|
||||
m.update(json.dumps(self.target, sort_keys=True).encode())
|
||||
m.update(json.dumps(self.options, sort_keys=True).encode())
|
||||
|
|
|
|||
22
test/mod/test_mounts.py
Normal file
22
test/mod/test_mounts.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
|
||||
from osbuild.mounts import Mount
|
||||
from osbuild.meta import ModuleInfo
|
||||
|
||||
|
||||
def test_mount_calc_id_is_stable():
|
||||
info = Mock(spec=ModuleInfo)
|
||||
info.name = "some-name"
|
||||
device = Mock(spec=ModuleInfo)
|
||||
device.id = "some-id"
|
||||
partition = 1
|
||||
target = "/"
|
||||
opts = {"opt1": 1}
|
||||
# make sure to update Mount.calc_id and this test when adding
|
||||
# parameters here
|
||||
mount1 = Mount("name", info, device, partition, target, opts)
|
||||
assert mount1.id == "15066da9ff760a60f1d1a360de2ad584cc0c97d6f6034e3258b3275ba3da6bb2"
|
||||
mount2 = Mount("name", info, device, partition, target, opts)
|
||||
assert mount1.id == mount2.id
|
||||
Loading…
Add table
Add a link
Reference in a new issue