Fix tests
This commit is contained in:
parent
1e996f4a43
commit
8774d019d3
2 changed files with 30 additions and 15 deletions
|
|
@ -31,7 +31,10 @@ def test_manifest_uses_jinjaturtle_templates_and_does_not_copy_raw(
|
||||||
"foo": {
|
"foo": {
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"arches": [],
|
"arches": [],
|
||||||
"installations": [{"version": "1.0", "arch": "amd64"}],
|
"installations": [
|
||||||
|
{"version": "1.0", "arch": "amd64", "section": "utils"}
|
||||||
|
],
|
||||||
|
"section": "utils",
|
||||||
"observed_via": [{"kind": "systemd_unit", "ref": "foo.service"}],
|
"observed_via": [{"kind": "systemd_unit", "ref": "foo.service"}],
|
||||||
"roles": ["foo"],
|
"roles": ["foo"],
|
||||||
}
|
}
|
||||||
|
|
@ -120,16 +123,16 @@ def test_manifest_uses_jinjaturtle_templates_and_does_not_copy_raw(
|
||||||
|
|
||||||
manifest_mod.manifest(str(bundle), str(out), jinjaturtle="on")
|
manifest_mod.manifest(str(bundle), str(out), jinjaturtle="on")
|
||||||
|
|
||||||
# Template should exist in the role.
|
role_dir = out / "roles" / "utils"
|
||||||
assert (out / "roles" / "foo" / "templates" / "etc" / "foo.ini.j2").exists()
|
|
||||||
|
# Template should exist in the grouped section role.
|
||||||
|
assert (role_dir / "templates" / "etc" / "foo.ini.j2").exists()
|
||||||
|
|
||||||
# Raw file should NOT be copied into role files/ because it was templatised.
|
# Raw file should NOT be copied into role files/ because it was templatised.
|
||||||
assert not (out / "roles" / "foo" / "files" / "etc" / "foo.ini").exists()
|
assert not (role_dir / "files" / "etc" / "foo.ini").exists()
|
||||||
|
|
||||||
# Defaults should include jinjaturtle vars.
|
# Defaults should include jinjaturtle vars.
|
||||||
defaults = (out / "roles" / "foo" / "defaults" / "main.yml").read_text(
|
defaults = (role_dir / "defaults" / "main.yml").read_text(encoding="utf-8")
|
||||||
encoding="utf-8"
|
|
||||||
)
|
|
||||||
assert "foo_key: 1" in defaults
|
assert "foo_key: 1" in defaults
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,20 @@ def test_manifest_emits_symlink_tasks_and_vars(tmp_path: Path):
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
"host": {"hostname": "test", "os": "debian", "pkg_backend": "dpkg"},
|
"host": {"hostname": "test", "os": "debian", "pkg_backend": "dpkg"},
|
||||||
"inventory": {"packages": {}},
|
"inventory": {
|
||||||
|
"packages": {
|
||||||
|
"nginx": {
|
||||||
|
"version": "1.0",
|
||||||
|
"arches": ["amd64"],
|
||||||
|
"installations": [
|
||||||
|
{"version": "1.0", "arch": "amd64", "section": "httpd"}
|
||||||
|
],
|
||||||
|
"section": "httpd",
|
||||||
|
"observed_via": [{"kind": "systemd_unit", "ref": "nginx.service"}],
|
||||||
|
"roles": ["nginx"],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"roles": {
|
"roles": {
|
||||||
"users": {
|
"users": {
|
||||||
"role_name": "users",
|
"role_name": "users",
|
||||||
|
|
@ -83,14 +96,13 @@ def test_manifest_emits_symlink_tasks_and_vars(tmp_path: Path):
|
||||||
|
|
||||||
manifest.manifest(str(bundle), str(out))
|
manifest.manifest(str(bundle), str(out))
|
||||||
|
|
||||||
tasks = (out / "roles" / "nginx" / "tasks" / "main.yml").read_text(encoding="utf-8")
|
role_dir = out / "roles" / "httpd"
|
||||||
|
tasks = (role_dir / "tasks" / "main.yml").read_text(encoding="utf-8")
|
||||||
assert "- name: Ensure managed symlinks exist" in tasks
|
assert "- name: Ensure managed symlinks exist" in tasks
|
||||||
assert 'loop: "{{ nginx_managed_links | default([]) }}"' in tasks
|
assert 'loop: "{{ httpd_managed_links | default([]) }}"' in tasks
|
||||||
|
|
||||||
defaults = (out / "roles" / "nginx" / "defaults" / "main.yml").read_text(
|
defaults = (role_dir / "defaults" / "main.yml").read_text(encoding="utf-8")
|
||||||
encoding="utf-8"
|
# The grouped role defaults should include the converted link mapping.
|
||||||
)
|
assert "httpd_managed_links:" in defaults
|
||||||
# The role defaults should include the converted link mapping.
|
|
||||||
assert "nginx_managed_links:" in defaults
|
|
||||||
assert "dest: /etc/nginx/sites-enabled/default" in defaults
|
assert "dest: /etc/nginx/sites-enabled/default" in defaults
|
||||||
assert "src: ../sites-available/default" in defaults
|
assert "src: ../sites-available/default" in defaults
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue