Files
nixpkgs/pkgs/development/ruby-modules/testing/assertions.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

35 lines
1.0 KiB
Nix

{ test, lib, ... }:
{
equal =
expected: actual:
if actual == expected then
(test.passed "= ${toString expected}")
else
(test.failed (
"expected '${toString expected}'(${builtins.typeOf expected})"
+ " != "
+ "actual '${toString actual}'(${builtins.typeOf actual})"
));
beASet =
actual:
if builtins.isAttrs actual then
(test.passed "is a set")
else
(test.failed "is not a set, was ${builtins.typeOf actual}: ${toString actual}");
haveKeys =
expected: actual:
if builtins.all (ex: builtins.any (ac: ex == ac) (builtins.attrNames actual)) expected then
(test.passed "has expected keys")
else
(test.failed "keys differ: expected: [${lib.concatStringsSep ";" expected}] actual: [${lib.concatStringsSep ";" (builtins.attrNames actual)}]");
havePrefix =
expected: actual:
if lib.hasPrefix expected actual then
(test.passed "has prefix '${expected}'")
else
(test.failed "prefix '${expected}' not found in '${actual}'");
}