Fediversity/deployment/data-model-test.nix

65 lines
1.7 KiB
Nix

let
inherit (import ../default.nix { }) pkgs;
inherit (pkgs) lib;
eval =
module:
(lib.evalModules {
modules = [
module
./data-model.nix
];
}).config;
in
{
_class = "nix-unit";
test-eval = {
expr =
let
example = eval (
{ config, ... }:
let
inherit (config.resources.bar.runtime-environment) runtime-environment;
in
{
providers.ssh-host =
{ ... }:
{
system.stateVersion = "25.05";
};
resources.bar.runtime-environment.ssh-host = {
ssh = {
host = "localhost";
username = "root";
authentication.password = "";
};
};
deployments.baz = {
inherit runtime-environment;
application-configuration = {
mastodon = {
enable = true;
};
};
};
migrations.boo = {
inherit runtime-environment;
deployment = config.deployments.baz;
};
}
);
in
{
has-provider = lib.isAttrs example.providers.ssh-host;
has-resource = lib.isAttrs example.resources.bar.runtime-environment.ssh-host.module;
has-deployment = example.deployments.baz.application-configuration.mastodon.enable == true;
has-migration = lib.isAttrs example.migrations.boo.deployment;
};
expected = {
has-provider = true;
has-resource = true;
has-deployment = true;
has-migration = true;
};
};
}