tests/wakapi: switch to subest; add sqlite3 case

This commit is contained in:
NotAShelf 2025-01-03 08:19:49 +03:00
parent 3204e04a80
commit fde8246eb9
No known key found for this signature in database
GPG Key ID: EED98D11B85A2819

View File

@ -3,36 +3,63 @@ import ./make-test-python.nix (
{ {
name = "Wakapi"; name = "Wakapi";
nodes.machine = { nodes = {
services.wakapi = { wakapiPsql = {
enable = true; services.wakapi = {
settings = { enable = true;
server.port = 3000; # upstream default, set explicitly in case upstream changes it settings = {
server.port = 3000; # upstream default, set explicitly in case upstream changes it
db = { db = {
dialect = "postgres"; # `createLocally` only supports postgres dialect = "postgres"; # `createLocally` only supports postgres
host = "/run/postgresql"; host = "/run/postgresql";
port = 5432; # service will fail if port is not set port = 5432; # service will fail if port is not set
name = "wakapi"; name = "wakapi";
user = "wakapi"; user = "wakapi";
};
}; };
# Automatically create our database
database.createLocally = true; # only works with Postgresql for now
# Created with `cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1`
# Prefer passwordSaltFile in production.
passwordSalt = "NpqCY7eY7fMoIWYmPx5mAgr6YoSlXSuI";
}; };
};
database.createLocally = true; wakapiSqlite = {
services.wakapi = {
enable = true;
settings = {
server.port = 3001;
db = {
dialect = "sqlite3";
name = "wakapi";
user = "wakapi";
};
};
# Created with `cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1` passwordSalt = "NpqCY7eY7fMoIWYmPx5mAgr6YoSlXSuI";
# Prefer passwordSaltFile in production. };
passwordSalt = "NpqCY7eY7fMoIWYmPx5mAgr6YoSlXSuI";
}; };
}; };
# Test that the service is running and that it is reachable. # Test that service works under both postgresql and sqlite3
# by starting all machines, and curling the default address.
# This is not very comprehensive for a test, but it should # This is not very comprehensive for a test, but it should
# catch very basic mistakes in the module. # catch very basic mistakes in the module.
testScript = '' testScript = ''
machine.wait_for_unit("wakapi.service") with subtest("Test Wakapi with postgresql backend"):
machine.wait_for_open_port(3000) wakapiPsql.start()
machine.succeed("curl --fail http://localhost:3000") wakapiPsql.wait_for_unit("wakapi.service")
wakapiPsql.wait_for_open_port(3000)
wakapiPsql.succeed("curl --fail http://localhost:3000")
with subtest("Test Wakapi with sqlite3 backend"):
wakapiSqlite.start()
wakapiSqlite.wait_for_unit("wakapi.service")
wakapiSqlite.wait_for_open_port(3001)
wakapiSqlite.succeed("curl --fail http://localhost:3001")
''; '';
meta.maintainers = [ lib.maintainers.NotAShelf ]; meta.maintainers = [ lib.maintainers.NotAShelf ];