@@ -32,38 +32,42 @@ def test_build_attr_to_attr() -> None:
3232
3333def test_flake_parse (tmpdir : Path , monkeypatch : MonkeyPatch ) -> None :
3434 assert m .Flake .parse ("/path/to/flake#attr" ) == m .Flake (
35- Path ("/path/to/flake" ), " nixosConfigurations.attr"
35+ Path ("/path/to/flake" ), ' nixosConfigurations." attr"'
3636 )
3737 assert m .Flake .parse ("/path/ to /flake" , lambda : "hostname" ) == m .Flake (
38- Path ("/path/ to /flake" ), " nixosConfigurations.hostname"
38+ Path ("/path/ to /flake" ), ' nixosConfigurations." hostname"'
3939 )
4040 assert m .Flake .parse ("/path/to/flake" , lambda : "hostname" ) == m .Flake (
41- Path ("/path/to/flake" ), " nixosConfigurations.hostname"
41+ Path ("/path/to/flake" ), ' nixosConfigurations." hostname"'
4242 )
4343 # change directory to tmpdir
4444 with monkeypatch .context () as patch_context :
4545 patch_context .chdir (tmpdir )
46- assert m .Flake .parse (".#attr" ) == m .Flake (Path ("." ), "nixosConfigurations.attr" )
47- assert m .Flake .parse ("#attr" ) == m .Flake (Path ("." ), "nixosConfigurations.attr" )
48- assert m .Flake .parse ("." ) == m .Flake (Path ("." ), "nixosConfigurations.default" )
46+ assert m .Flake .parse (".#attr" ) == m .Flake (
47+ Path ("." ), 'nixosConfigurations."attr"'
48+ )
49+ assert m .Flake .parse ("#attr" ) == m .Flake (
50+ Path ("." ), 'nixosConfigurations."attr"'
51+ )
52+ assert m .Flake .parse ("." ) == m .Flake (Path ("." ), 'nixosConfigurations."default"' )
4953 assert m .Flake .parse ("path:/to/flake#attr" ) == m .Flake (
50- "path:/to/flake" , " nixosConfigurations.attr"
54+ "path:/to/flake" , ' nixosConfigurations." attr"'
5155 )
5256 assert m .Flake .parse ("github:user/repo/branch" ) == m .Flake (
53- "github:user/repo/branch" , " nixosConfigurations.default"
57+ "github:user/repo/branch" , ' nixosConfigurations." default"'
5458 )
5559 git_root = tmpdir / "git_root"
5660 git_root .mkdir ()
5761 (git_root / ".git" ).mkdir ()
5862 assert m .Flake .parse (str (git_root )) == m .Flake (
59- f"git+file://{ git_root } " , " nixosConfigurations.default"
63+ f"git+file://{ git_root } " , ' nixosConfigurations." default"'
6064 )
6165
6266 work_tree = tmpdir / "work_tree"
6367 work_tree .mkdir ()
6468 (work_tree / ".git" ).write_text ("gitdir: /path/to/git" , "utf-8" )
6569 assert m .Flake .parse (str (work_tree )) == m .Flake (
66- "git+file:///path/to/git" , " nixosConfigurations.default"
70+ "git+file:///path/to/git" , ' nixosConfigurations." default"'
6771 )
6872
6973
@@ -84,7 +88,7 @@ def test_flake_from_arg(
8488
8589 # Flake string
8690 assert m .Flake .from_arg ("/path/to/flake#attr" , None ) == m .Flake (
87- Path ("/path/to/flake" ), " nixosConfigurations.attr"
91+ Path ("/path/to/flake" ), ' nixosConfigurations." attr"'
8892 )
8993
9094 # False
@@ -94,7 +98,7 @@ def test_flake_from_arg(
9498 with monkeypatch .context () as patch_context :
9599 patch_context .chdir (tmpdir )
96100 assert m .Flake .from_arg (True , None ) == m .Flake (
97- Path ("." ), " nixosConfigurations.hostname"
101+ Path ("." ), ' nixosConfigurations." hostname"'
98102 )
99103
100104 # None when we do not have /etc/nixos/flake.nix
@@ -124,7 +128,7 @@ def test_flake_from_arg(
124128 ),
125129 ):
126130 assert m .Flake .from_arg (None , None ) == m .Flake (
127- "git+file:///etc/nixos" , " nixosConfigurations.hostname"
131+ "git+file:///etc/nixos" , ' nixosConfigurations." hostname"'
128132 )
129133
130134 with (
@@ -145,7 +149,7 @@ def test_flake_from_arg(
145149 ),
146150 ):
147151 assert m .Flake .from_arg (None , None ) == m .Flake (
148- Path ("/path/to" ), " nixosConfigurations.hostname"
152+ Path ("/path/to" ), ' nixosConfigurations." hostname"'
149153 )
150154
151155 with (
@@ -156,7 +160,7 @@ def test_flake_from_arg(
156160 ),
157161 ):
158162 assert m .Flake .from_arg ("/path/to" , m .Remote ("user@host" , [], None )) == m .Flake (
159- Path ("/path/to" ), " nixosConfigurations.remote-hostname"
163+ Path ("/path/to" ), ' nixosConfigurations." remote-hostname"'
160164 )
161165
162166
0 commit comments