nixite/testing/it.nix

26 lines
503 B
Nix
Raw Normal View History

msg:
2024-01-01 06:33:57 +00:00
{ actual, expected, asString ? false, asJSON ? false, removeDunders ? false, }:
2024-01-01 08:10:32 +00:00
let
preProcess = v:
if removeDunders then
builtins.removeAttrs v [ "__toString" "__functor" ]
else if asString then
toString v
else if asJSON then
builtins.toJSON v
else v;
a = preProcess actual;
e = preProcess expected;
in
if (a == e) then ''
echo 'it ${msg}'
2024-01-01 08:10:32 +00:00
''
else
''
echo 'FAILED: ${msg}'
echo '${builtins.toJSON expected}'
echo '${builtins.toJSON actual}'
''