chore: add nixtest for testing and a couple of tests

This commit is contained in:
technofab 2026-01-04 21:26:08 +01:00
parent e08c48b5db
commit e6c13290bb
Signed by: technofab
SSH key fingerprint: SHA256:bV4h88OqS/AxjbPn66uUdvK9JsgIW4tv3vwJQ8tpMqQ
8 changed files with 281 additions and 0 deletions

57
tests/loader_test.nix Normal file
View file

@ -0,0 +1,57 @@
{
pkgs,
ntlib,
rensa,
...
}: {
suites."Loader" = {
pos = __curPos;
tests = [
{
name = "cell sibling access";
expected = {
hello = "world";
};
actual = let
testFlake = rensa.build {
inputs = {};
cellsFrom = ../cells;
cellBlocks = with rensa.blocks; [
(simple "test")
];
systems = ["x86_64-linux"];
};
in
testFlake.x86_64-linux.test.test;
}
{
name = "load file";
type = "script";
script = ''
${ntlib.helpers.path [pkgs.gnugrep pkgs.coreutils pkgs.nix]}
${ntlib.helpers.scriptHelpers}
mkdir -p "cells/testcell"
echo '{ hello = "world"; }' > "cells/testcell/packages.nix"
cat > "flake.nix" << 'EOF'
{
outputs = inputs: let
rensa = import ${../lib} { lib = import "${pkgs.path}/lib"; };
in rensa.build {
inputs = {};
cellsFrom = ./cells;
cellBlocks = with rensa.blocks; [ (simple "packages") ];
systems = [ "x86_64-linux" ];
};
}
EOF
result=$(nix eval --impure .#x86_64-linux.testcell.packages.hello)
assert "$result == \"world\"" "should equal to world"
'';
}
];
};
}