vars: delete duplicate shared flag test

This commit is contained in:
Jörg Thalheim
2024-12-17 17:10:22 +01:00
parent 8cc41f543a
commit 0ab3ec5e16

View File

@@ -501,73 +501,6 @@ def test_prompt(
)
@pytest.mark.with_core
def test_share_flag(
monkeypatch: pytest.MonkeyPatch,
flake: ClanFlake,
sops_setup: SopsSetup,
) -> None:
config = flake.machines["my_machine"]
config["nixpkgs"]["hostPlatform"] = "x86_64-linux"
shared_generator = config["clan"]["core"]["vars"]["generators"]["shared_generator"]
shared_generator["share"] = True
shared_generator["files"]["my_secret"]["secret"] = True
shared_generator["files"]["my_value"]["secret"] = False
shared_generator["script"] = (
"echo hello > $out/my_secret && echo hello > $out/my_value"
)
unshared_generator = config["clan"]["core"]["vars"]["generators"][
"unshared_generator"
]
unshared_generator["share"] = False
unshared_generator["files"]["my_secret"]["secret"] = True
unshared_generator["files"]["my_value"]["secret"] = False
unshared_generator["script"] = (
"echo hello > $out/my_secret && echo hello > $out/my_value"
)
flake.refresh()
monkeypatch.chdir(flake.path)
sops_setup.init()
machine = Machine(name="my_machine", flake=FlakeId(str(flake.path)))
assert not check_vars(machine)
cli.run(["vars", "generate", "--flake", str(flake.path), "my_machine"])
assert check_vars(machine)
sops_store = sops.SecretStore(
Machine(name="my_machine", flake=FlakeId(str(flake.path)))
)
in_repo_store = in_repo.FactStore(
Machine(name="my_machine", flake=FlakeId(str(flake.path)))
)
# check secrets stored correctly
assert sops_store.exists(Generator("shared_generator", share=True), "my_secret")
assert not sops_store.exists(
Generator("shared_generator", share=False), "my_secret"
)
assert sops_store.exists(Generator("unshared_generator", share=False), "my_secret")
assert not sops_store.exists(
Generator("unshared_generator", share=True), "my_secret"
)
# check values stored correctly
assert in_repo_store.exists(Generator("shared_generator", share=True), "my_value")
assert not in_repo_store.exists(
Generator("shared_generator", share=False), "my_value"
)
assert in_repo_store.exists(
Generator("unshared_generator", share=False), "my_value"
)
assert not in_repo_store.exists(
Generator("unshared_generator", share=True), "my_value"
)
vars_eval = run(
nix_eval(
[
f"{flake.path}#nixosConfigurations.my_machine.config.clan.core.vars.generators.shared_generator.files.my_value.value",
]
)
).stdout.strip()
assert json.loads(vars_eval) == "hello\n"
@pytest.mark.with_core
def test_multi_machine_shared_vars(
monkeypatch: pytest.MonkeyPatch,