Skip to content

Commit b36f9f0

Browse files
committed
add test cases for local+remote flakes, and nixpkgs references
1 parent a5f7f36 commit b36f9f0

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

internal/devconfig/packages_test.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,56 @@ func TestJsonifyConfigPackages(t *testing.T) {
118118
},
119119
},
120120
},
121+
{
122+
name: "map-with-platforms-and-excluded-platforms-local-flake",
123+
jsonConfig: `{"packages":{"path:my-php-flake#hello":{"version":"latest",` +
124+
`"platforms":["x86_64-darwin","aarch64-linux"],` +
125+
`"excluded_platforms":["x86_64-linux"]}}}`,
126+
expected: Packages{
127+
jsonKind: jsonMap,
128+
Collection: []Package{
129+
NewPackage("path:my-php-flake#hello", map[string]any{
130+
"version": "latest",
131+
"platforms": []string{"x86_64-darwin", "aarch64-linux"},
132+
"excluded_platforms": []string{"x86_64-linux"},
133+
}),
134+
},
135+
},
136+
},
137+
{
138+
name: "map-with-platforms-and-excluded-platforms-remote-flake",
139+
jsonConfig: `{"packages":{"github:F1bonacc1/process-compose/v0.43.1":` +
140+
`{"version":"latest",` +
141+
`"platforms":["x86_64-darwin","aarch64-linux"],` +
142+
`"excluded_platforms":["x86_64-linux"]}}}`,
143+
expected: Packages{
144+
jsonKind: jsonMap,
145+
Collection: []Package{
146+
NewPackage("github:F1bonacc1/process-compose/v0.43.1", map[string]any{
147+
"version": "latest",
148+
"platforms": []string{"x86_64-darwin", "aarch64-linux"},
149+
"excluded_platforms": []string{"x86_64-linux"},
150+
}),
151+
},
152+
},
153+
},
154+
{
155+
name: "map-with-platforms-and-excluded-platforms-nixpkgs-reference",
156+
jsonConfig: `{"packages":{"github:nixos/nixpkgs/5233fd2ba76a3accb5aaa999c00509a11fd0793c#hello":` +
157+
`{"version":"latest",` +
158+
`"platforms":["x86_64-darwin","aarch64-linux"],` +
159+
`"excluded_platforms":["x86_64-linux"]}}}`,
160+
expected: Packages{
161+
jsonKind: jsonMap,
162+
Collection: []Package{
163+
NewPackage("github:nixos/nixpkgs/5233fd2ba76a3accb5aaa999c00509a11fd0793c#hello", map[string]any{
164+
"version": "latest",
165+
"platforms": []string{"x86_64-darwin", "aarch64-linux"},
166+
"excluded_platforms": []string{"x86_64-linux"},
167+
}),
168+
},
169+
},
170+
},
121171
}
122172

123173
for _, testCase := range testCases {
@@ -195,6 +245,24 @@ func TestParseVersionedName(t *testing.T) {
195245
expectedName: "emacsPackages.@",
196246
expectedVersion: "",
197247
},
248+
{
249+
name: "local-flake",
250+
input: "path:my-php-flake#hello",
251+
expectedName: "path:my-php-flake#hello",
252+
expectedVersion: "",
253+
},
254+
{
255+
name: "remote-flake",
256+
input: "github:F1bonacc1/process-compose/v0.43.1",
257+
expectedName: "github:F1bonacc1/process-compose/v0.43.1",
258+
expectedVersion: "",
259+
},
260+
{
261+
name: "nixpkgs-reference",
262+
input: "github:nixos/nixpkgs/5233fd2ba76a3accb5aaa999c00509a11fd0793c#hello",
263+
expectedName: "github:nixos/nixpkgs/5233fd2ba76a3accb5aaa999c00509a11fd0793c#hello",
264+
expectedVersion: "",
265+
},
198266
}
199267

200268
for _, testCase := range testCases {

0 commit comments

Comments
 (0)