test(persist/inventory): add test for adding deferredModule

This feature will allow us to read/write to 'settings' of service
'instances' which are of type deferredModule.
Usually a deferredModule needs to be evaulated, but because we use our
own type, which forces some constraints, we can safely perform read and
write
This commit is contained in:
Johannes Kirschbauer
2025-05-23 21:49:16 +02:00
parent 9cea8e8901
commit a7f4927e0c
3 changed files with 78 additions and 0 deletions

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1,28 @@
{ clanLib, lib, ... }:
let
eval = lib.evalModules {
modules = [
{
# Trying to write into the default
options.foo = lib.mkOption {
type = lib.types.attrsOf clanLib.types.uniqueDeferredSerializableModule;
};
}
{
foo = {
a = { };
b = { };
};
}
# Merge the "inventory.json"
(builtins.fromJSON (builtins.readFile ./deferred.json))
];
};
in
{
clanInternals.inventoryClass.inventory = eval.config;
clanInternals.inventoryClass.introspection = clanLib.introspection.getPrios {
options = eval.options;
};
}