bundles/apt: fix metadata key mess (unattended-upgrades vs unattended_upgrades)
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
07157b6335
commit
0ccb983b28
13 changed files with 66 additions and 28 deletions
45
hooks/test_metadata_dashes_vs_underscores.py
Normal file
45
hooks/test_metadata_dashes_vs_underscores.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
from collections.abc import Mapping
|
||||
|
||||
from bundlewrap.exceptions import BundleError
|
||||
from bundlewrap.utils.text import bold, green
|
||||
from bundlewrap.utils.ui import io
|
||||
|
||||
def test_underscore_vs_dash(node, metadata, path=[]):
|
||||
for k, v in metadata.items():
|
||||
if not isinstance(k, str):
|
||||
continue
|
||||
|
||||
all_dashes = k.replace('_', '-')
|
||||
all_underscores = k.replace('-', '_')
|
||||
|
||||
if k != all_dashes and all_dashes in metadata:
|
||||
raise BundleError('{n} metadata contains both {k} and {p}'.format(
|
||||
n=node.name,
|
||||
k='/'.join(path + [k]),
|
||||
p='/'.join(path + [all_dashes]),
|
||||
))
|
||||
|
||||
if k != all_underscores and all_underscores in metadata:
|
||||
raise BundleError('{n} metadata contains both {k} and {p}'.format(
|
||||
n=node.name,
|
||||
k='/'.join(path + [k]),
|
||||
p='/'.join(path + [all_underscores]),
|
||||
))
|
||||
|
||||
if isinstance(v, Mapping):
|
||||
test_underscore_vs_dash(
|
||||
node,
|
||||
v,
|
||||
path + [k],
|
||||
)
|
||||
|
||||
def test_node(repo, node, **kwargs):
|
||||
test_underscore_vs_dash(
|
||||
node,
|
||||
node.metadata.get(tuple()),
|
||||
)
|
||||
|
||||
io.stdout('{x} {node} metadata contains no dashes-vs-underscores errors'.format(
|
||||
x=green("✓"),
|
||||
node=bold(node.name),
|
||||
))
|
Loading…
Add table
Add a link
Reference in a new issue