Reconcile reef bindings and evidence
This commit is contained in:
parent
721398125b
commit
3e98b10d81
15 changed files with 541 additions and 36 deletions
65
tests/test_binding_projection.py
Normal file
65
tests/test_binding_projection.py
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
import importlib.util
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
MODULE = Path(__file__).parents[1] / "tools/check_binding_projection.py"
|
||||
SPEC = importlib.util.spec_from_file_location("binding_projection", MODULE)
|
||||
binding_projection = importlib.util.module_from_spec(SPEC)
|
||||
SPEC.loader.exec_module(binding_projection)
|
||||
|
||||
|
||||
def write_yaml(path: Path, value: dict) -> None:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(yaml.safe_dump(value, sort_keys=False), encoding="utf-8")
|
||||
|
||||
|
||||
def test_matching_projection_passes(tmp_path):
|
||||
repo = tmp_path / "reef-example"
|
||||
write_yaml(
|
||||
repo / "declarations/reef.yaml",
|
||||
{"reef_id": "reef-example", "hosted_rails": ["rail-kubernetes"]},
|
||||
)
|
||||
write_yaml(
|
||||
repo / "bindings/rails.yaml",
|
||||
{"hosted_rails": [{"rail_id": "rail-kubernetes"}]},
|
||||
)
|
||||
write_yaml(
|
||||
repo / "bindings/rapps.yaml",
|
||||
{"bound_rapps": [{"rapp_id": "rapp-example"}]},
|
||||
)
|
||||
write_yaml(
|
||||
tmp_path / "rail-kubernetes/declarations/rail.yaml",
|
||||
{"rail_id": "rail-kubernetes"},
|
||||
)
|
||||
write_yaml(
|
||||
tmp_path / "rapp-example/declarations/rapp.yaml",
|
||||
{"rapp_id": "rapp-example", "bound_reefs": ["reef-example"]},
|
||||
)
|
||||
|
||||
assert binding_projection.assess(repo, tmp_path) == []
|
||||
|
||||
|
||||
def test_stale_rapp_projection_fails(tmp_path):
|
||||
repo = tmp_path / "reef-example"
|
||||
write_yaml(
|
||||
repo / "declarations/reef.yaml",
|
||||
{"reef_id": "reef-example", "hosted_rails": ["rail-kubernetes"]},
|
||||
)
|
||||
write_yaml(
|
||||
repo / "bindings/rails.yaml",
|
||||
{"hosted_rails": [{"rail_id": "rail-kubernetes"}]},
|
||||
)
|
||||
write_yaml(repo / "bindings/rapps.yaml", {"bound_rapps": []})
|
||||
write_yaml(
|
||||
tmp_path / "rail-kubernetes/declarations/rail.yaml",
|
||||
{"rail_id": "rail-kubernetes"},
|
||||
)
|
||||
write_yaml(
|
||||
tmp_path / "rapp-example/declarations/rapp.yaml",
|
||||
{"rapp_id": "rapp-example", "bound_reefs": ["reef-example"]},
|
||||
)
|
||||
|
||||
failures = binding_projection.assess(repo, tmp_path)
|
||||
assert failures and "rapp projection differs" in failures[0]
|
||||
Loading…
Add table
Add a link
Reference in a new issue