Files
clan-core/nixosModules/clanCore/postgresql/tests/flake-module.nix
2025-08-14 12:02:40 +02:00

57 lines
1.6 KiB
Nix

{ ... }:
{
perSystem =
{ ... }:
{
clan.nixosTests.postgresql = {
name = "service-postgresql";
clan = {
directory = ./.;
# Workaround until we can use nodes.machine = { };
modules."@clan/importer" = ../../../../clanServices/importer;
inventory = {
machines.machine = { };
instances.importer = {
module.name = "@clan/importer";
module.input = "self";
roles.default.tags.all = { };
roles.default.extraModules = [
{
clan.core.postgresql.enable = true;
clan.core.postgresql.users.test = { };
clan.core.postgresql.databases.test.create.options.OWNER = "test";
clan.core.settings.directory = ./.;
}
];
};
};
};
# TODO: Broken. Use instead of importer after fixing.
# nodes.machine = { };
testScript =
let
runpg = "runuser -u postgres -- /run/current-system/sw/bin/psql";
in
''
start_all()
machine.wait_for_unit("postgresql")
# Create a test table
machine.succeed("${runpg} -c 'CREATE TABLE test (id serial PRIMARY KEY);' test")
# Insert valuesn
machine.succeed("${runpg} -d test -c 'INSERT INTO test DEFAULT VALUES;'")
# Check that we can read them back
machine.succeed("${runpg} -d test -c 'SELECT * FROM test;'")
'';
};
};
}