at 23.05-pre 1.8 kB view raw
1import ./make-test-python.nix ({ pkgs, lib, ... }: 2{ 3 name = "hedgedoc"; 4 5 meta = with lib.maintainers; { 6 maintainers = [ willibutz ]; 7 }; 8 9 nodes = { 10 hedgedocSqlite = { ... }: { 11 services = { 12 hedgedoc = { 13 enable = true; 14 settings.dbURL = "sqlite:///var/lib/hedgedoc/hedgedoc.db"; 15 }; 16 }; 17 }; 18 19 hedgedocPostgres = { ... }: { 20 systemd.services.hedgedoc.after = [ "postgresql.service" ]; 21 services = { 22 hedgedoc = { 23 enable = true; 24 settings.dbURL = "postgres://hedgedoc:\${DB_PASSWORD}@localhost:5432/hedgedocdb"; 25 26 /* 27 * Do not use pkgs.writeText for secrets as 28 * they will end up in the world-readable Nix store. 29 */ 30 environmentFile = pkgs.writeText "hedgedoc-env" '' 31 DB_PASSWORD=snakeoilpassword 32 ''; 33 }; 34 postgresql = { 35 enable = true; 36 initialScript = pkgs.writeText "pg-init-script.sql" '' 37 CREATE ROLE hedgedoc LOGIN PASSWORD 'snakeoilpassword'; 38 CREATE DATABASE hedgedocdb OWNER hedgedoc; 39 ''; 40 }; 41 }; 42 }; 43 }; 44 45 testScript = '' 46 start_all() 47 48 with subtest("HedgeDoc sqlite"): 49 hedgedocSqlite.wait_for_unit("hedgedoc.service") 50 hedgedocSqlite.wait_for_open_port(3000) 51 hedgedocSqlite.wait_until_succeeds("curl -sSf http://localhost:3000/new") 52 53 with subtest("HedgeDoc postgres"): 54 hedgedocPostgres.wait_for_unit("postgresql.service") 55 hedgedocPostgres.wait_for_unit("hedgedoc.service") 56 hedgedocPostgres.wait_for_open_port(5432) 57 hedgedocPostgres.wait_for_open_port(3000) 58 hedgedocPostgres.wait_until_succeeds("curl -sSf http://localhost:3000/new") 59 ''; 60})