mirror of
https://gitlab.com/rensa-nix/core.git
synced 2026-02-02 07:15:08 +01:00
chore: add nixtest for testing and a couple of tests
This commit is contained in:
parent
e08c48b5db
commit
e6c13290bb
8 changed files with 281 additions and 0 deletions
57
tests/loader_test.nix
Normal file
57
tests/loader_test.nix
Normal 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"
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue