testing: migrate flakes/flakes.sh (part 15)
flake follows handling during locking Change-Id: Ia3f2b7a8df1d0ec51fd97d14d49788b33dda7754
This commit is contained in:
@@ -215,47 +215,6 @@ git -C $flake3Dir add flake.nix flake.lock
|
||||
git -C $flake3Dir commit -m 'Remove packages.xyzzy'
|
||||
git -C $flake3Dir checkout master
|
||||
|
||||
# Test 'follows' inputs.
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
{
|
||||
inputs.foo = {
|
||||
type = "indirect";
|
||||
id = "flake1";
|
||||
};
|
||||
inputs.bar.follows = "foo";
|
||||
|
||||
outputs = { self, foo, bar }: {
|
||||
};
|
||||
}
|
||||
EOF
|
||||
|
||||
nix flake lock $flake3Dir
|
||||
[[ $(jq -c .nodes.root.inputs.bar $flake3Dir/flake.lock) = '["foo"]' ]]
|
||||
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
{
|
||||
inputs.bar.follows = "flake2/flake1";
|
||||
|
||||
outputs = { self, flake2, bar }: {
|
||||
};
|
||||
}
|
||||
EOF
|
||||
|
||||
nix flake lock $flake3Dir
|
||||
[[ $(jq -c .nodes.root.inputs.bar $flake3Dir/flake.lock) = '["flake2","flake1"]' ]]
|
||||
|
||||
cat > $flake3Dir/flake.nix <<EOF
|
||||
{
|
||||
inputs.bar.follows = "flake2";
|
||||
|
||||
outputs = { self, flake2, bar }: {
|
||||
};
|
||||
}
|
||||
EOF
|
||||
|
||||
nix flake lock $flake3Dir
|
||||
[[ $(jq -c .nodes.root.inputs.bar $flake3Dir/flake.lock) = '["flake2"]' ]]
|
||||
|
||||
# Test overriding inputs of inputs.
|
||||
writeTrivialFlake $flake7Dir
|
||||
git -C $flake7Dir add flake.nix
|
||||
|
||||
@@ -577,6 +577,41 @@ class TestLock:
|
||||
assert lock["nodes"]["flake1"]["locked"]["rev"] == flake1_modified_commit
|
||||
assert lock["nodes"]["flake1_2"]["locked"]["rev"] == flake1_modified_commit
|
||||
|
||||
class TestFollows:
|
||||
def test_simple_explicit(self, nix: Nix, flake3: Path):
|
||||
(flake3 / "flake.nix").write_text("""{
|
||||
inputs.foo = {
|
||||
type = "indirect";
|
||||
id = "flake1";
|
||||
};
|
||||
inputs.bar.follows = "foo";
|
||||
|
||||
outputs = { self, foo, bar }: {};
|
||||
}""")
|
||||
nix.nix(["flake", "lock", flake3]).run().ok()
|
||||
lock = json.loads((flake3 / "flake.lock").read_text())
|
||||
assert lock["nodes"]["root"]["inputs"]["bar"] == ["foo"]
|
||||
|
||||
def test_nested_implicit(self, nix: Nix, flake3: Path):
|
||||
(flake3 / "flake.nix").write_text("""{
|
||||
inputs.bar.follows = "flake2/flake1";
|
||||
|
||||
outputs = { self, flake2, bar }: {};
|
||||
}""")
|
||||
nix.nix(["flake", "lock", flake3]).run().ok()
|
||||
lock = json.loads((flake3 / "flake.lock").read_text())
|
||||
assert lock["nodes"]["root"]["inputs"]["bar"] == ["flake2", "flake1"]
|
||||
|
||||
def test_simple_implicit(self, nix: Nix, flake3: Path):
|
||||
(flake3 / "flake.nix").write_text("""{
|
||||
inputs.bar.follows = "flake2";
|
||||
|
||||
outputs = { self, flake2, bar }: {};
|
||||
}""")
|
||||
nix.nix(["flake", "lock", flake3]).run().ok()
|
||||
lock = json.loads((flake3 / "flake.lock").read_text())
|
||||
assert lock["nodes"]["root"]["inputs"]["bar"] == ["flake2"]
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("registry")
|
||||
class TestMetadata:
|
||||
|
||||
Reference in New Issue
Block a user