feat: add support for pretty/nix format

improve handling string test values
This commit is contained in:
technofab 2025-05-10 21:55:08 +02:00
parent 0a1bbae2c3
commit e029fae0b8
4 changed files with 52 additions and 14 deletions

View file

@ -8,14 +8,20 @@
type ? "unit",
name,
description ? "",
format ? "json",
expected ? null,
actual ? null,
actualDrv ? null,
pos ? null,
}: let
fileRelative = lib.removePrefix ((toString self) + "/") pos.file;
actual' =
if format == "json"
then actual
else lib.generators.toPretty {} actual;
in {
inherit type name description expected actual;
inherit type name description expected;
actual = actual';
# discard string context, otherwise it's being built instantly which we don't want
actualDrv = builtins.unsafeDiscardStringContext (actualDrv.drvPath or "");
pos =