dream2nix/tests/nix-unit/test_graph_utils/sanitizeGraph.nix
Johannes Kirschbauer a27d3894ae
Feat/group pkgs versions (#757)
* add derived graph

* rework graph sanitizing based on list keys

* figure out details for builder

* format stuff!

* try get groups working

* nodejs: fixups for new v3 builder

Co-authored-by: Johannes Kirschbauer <hsjobeki@gmail.com>

---------

Co-authored-by: DavHau <hsngrmpf+github@gmail.com>
2024-01-18 19:56:00 +07:00

118 lines
2.2 KiB
Nix

{lib ? import <nixpkgs/lib>, ...}: let
util = import ../../../lib/internal/graphUtils.nix {inherit lib;};
in {
test_simple = {
expr = util.sanitizeGraph {
root = {
name = "a";
version = "1.0.0";
};
graph = {
a."1.0.0" = {
dependencies = {
b.version = "1.0.0";
};
dev = true;
};
b."1.0.0" = {
dependencies = {
a.version = "1.0.0";
};
dev = true;
};
};
};
expected = [
{
isRoot = true;
key = ["a" "1.0.0"];
name = "a";
version = "1.0.0";
}
{
dev = true;
key = ["b" "1.0.0"];
name = "b";
parent = {
name = "a";
version = "1.0.0";
};
version = "1.0.0";
}
];
};
test_two_cycles = {
expr = util.sanitizeGraph {
root = {
name = "a";
version = "1.0.0";
};
graph = {
a."1.0.0" = {
dependencies = {
c.version = "1.0.0";
};
dev = true;
};
b."1.0.0" = {
dependencies = {
c.version = "1.0.0";
};
dev = true;
};
c."1.0.0" = {
dependencies = {
d.version = "1.0.0";
};
dev = true;
};
d."1.0.0" = {
dependencies = {
a.version = "1.0.0";
b.version = "1.0.0";
};
dev = true;
};
};
};
expected = [
{
isRoot = true;
key = ["a" "1.0.0"];
name = "a";
version = "1.0.0";
}
{
dev = true;
key = ["c" "1.0.0"];
name = "c";
parent = {
name = "a";
version = "1.0.0";
};
version = "1.0.0";
}
{
dev = true;
key = ["d" "1.0.0"];
name = "d";
parent = {
name = "c";
version = "1.0.0";
};
version = "1.0.0";
}
{
dev = true;
key = ["b" "1.0.0"];
name = "b";
parent = {
name = "d";
version = "1.0.0";
};
version = "1.0.0";
}
];
};
}