From cd6803412680c2d62187c6da399e6afa951970e6 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Mon, 30 Sep 2024 18:05:50 +0200 Subject: [PATCH] lib/tests: test `filterAttrs` --- lib/tests/misc.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index 116d86cdfb3fb..72b3d630b8da8 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -47,6 +47,7 @@ let evalModules extends filter + filterAttrs fix fold foldAttrs @@ -1102,6 +1103,25 @@ runTests { }; }; + testFilterAttrs = { + expr = filterAttrs (n: v: n != "a" && (v.hello or false) == true) { + a.hello = true; + b.hello = true; + c = { + hello = true; + world = false; + }; + d.hello = false; + }; + expected = { + b.hello = true; + c = { + hello = true; + world = false; + }; + }; + }; + # code from example testFoldlAttrs = { expr = {