WIP: installer, profile, resolve, cli

This commit is contained in:
Sprite committed 2026-11-24 21:54:07 +00:00
1 parent 988c942952
commit b3d95bb012
20 files changed
+1274 -2

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
///|
test "channel mapping" {
let c = Channel::parse("nixos-unstable")
inspect(
c.job_url("hello", "x86_64-linux"),
content="https://hydra.nixos.org/job/nixpkgs/trunk/hello.x86_64-linux/latest-finished",
)
let r = Channel::parse("nixos-25.05")
inspect(
r.job_url("hello", "x86_64-linux"),
content="https://hydra.nixos.org/job/nixos/release-25.05/nixpkgs.hello.x86_64-linux/latest-finished",
)
assert_true(@store.raises(() => Channel::parse("bogus")))
assert_true(@store.raises(() => c.job_url("a/b", "x86_64-linux")))
}
///|
test "parse hydra build json (real response shape)" {
let text =
#|{"system":"x86_64-linux","finished":1,"buildstatus":0,"nixname":"hello-2.12.3","buildoutputs":{"out":{"path":"/nix/store/dcg4mi1h810kl0q5skk995b8nb2idg1g-hello-2.12.3"}}}
let (p, n) = parse_hydra_build(text)
inspect(p, content="/nix/store/dcg4mi1h810kl0q5skk995b8nb2idg1g-hello-2.12.3")
inspect(n, content="hello-2.12.3")
assert_true(
@store.raises(() => {
parse_hydra_build("{\"error\":\"There is no successful build\"}")
}),
)
assert_true(@store.raises(() => parse_hydra_build("not json")))
assert_true(
@store.raises(() => {
parse_hydra_build(
"{\"finished\":1,\"buildstatus\":1,\"buildoutputs\":{}}",
)
}),
)
}
///|
test "search ranks exact pname first" {
let paths = parse_store_paths(
(
#|/nix/store/8padfyi6z9ipfq35j86krpvpvx3j3r3v-hello-2.8.4
#|/nix/store/2w75rgswbbfgj1910mw7w5lz0cf6rxfr-hello-1.0.0.2
#|/nix/store/2w75rgswbbfgj1910mw7w5lz0cf6rxfr-hello-1.0.0.2
#|/nix/store/266xlfadj5g19isr0ygn0nz9jbgmvhrd-akku-retropikzel-hello-1.2.3
#|/nix/store/76bbldfx3g88jxaqjakksgc5mvl1c3kb-ripgrep-15.2.0
),
)
let r = search(paths, "hello")
assert_eq(r.length(), 3)
assert_eq(r[0].0.has_prefix("hello-"), true)
assert_eq(r[2].0, "akku-retropikzel-hello-1.2.3")
assert_eq(search(paths, "HELLO").length(), 3)
assert_eq(search(paths, "zzz").length(), 0)
}