23 lines
968 B
Python
23 lines
968 B
Python
from pathlib import Path
|
|
import yaml
|
|
|
|
ROOT = Path(__file__).parents[1]
|
|
|
|
def service():
|
|
return yaml.safe_load((ROOT / "examples/service.yaml").read_text())
|
|
|
|
def test_safe_generic_service():
|
|
item = service()
|
|
assert item["apiVersion"] == "serving.knative.dev/v1"
|
|
assert item["metadata"]["annotations"]["serving.knative.dev/visibility"] == "cluster-local"
|
|
template = item["spec"]["template"]
|
|
assert template["metadata"]["annotations"]["autoscaling.knative.dev/min-scale"] == "0"
|
|
assert int(template["metadata"]["annotations"]["autoscaling.knative.dev/max-scale"]) > 0
|
|
assert template["spec"]["containerConcurrency"] > 0
|
|
assert "@sha256:" in template["spec"]["containers"][0]["image"]
|
|
assert "qonto" not in (ROOT / "examples/service.yaml").read_text().lower()
|
|
|
|
def test_traffic_is_deterministic():
|
|
traffic = service()["spec"]["traffic"]
|
|
assert len(traffic) == 1
|
|
assert sum(target["percent"] for target in traffic) == 100
|