From 0922b13db8eff1ab8819e3202d2045a32ec719bf Mon Sep 17 00:00:00 2001 From: John Hampton Date: Sat, 13 Apr 2024 17:56:50 -0700 Subject: [PATCH] test(postgres): set socketDir with empty listen_addresses Test a postgres service with socketDir set and empty listen_addresses. --- nix/postgres/postgres_test.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/nix/postgres/postgres_test.nix b/nix/postgres/postgres_test.nix index d2b0580e..1adf9789 100644 --- a/nix/postgres/postgres_test.nix +++ b/nix/postgres/postgres_test.nix @@ -16,8 +16,19 @@ } ]; }; + services.postgres."pg3" = { + enable = true; + socketDir = "./test/new/socket/path2"; + listen_addresses = ""; + initialDatabases = [ + { + name = "test-db"; + } + ]; + }; # avoid both the processes trying to create `data` directory at the same time settings.processes."pg2-init".depends_on."pg1-init".condition = "process_completed_successfully"; + settings.processes."pg3-init".depends_on."pg2-init".condition = "process_completed_successfully"; settings.processes.test = let cfg = config.services.postgres."pg1"; @@ -37,12 +48,16 @@ # schemas test echo "SELECT * from users where user_name = 'test_user';" | psql -h 127.0.0.1 -p 5433 -d sample-db | grep -q test_user + + # listen_addresses test + echo "SELECT 1 FROM pg_database where datname = 'test-db';" | psql -h "$(readlink -f ${config.services.postgres.pg3.socketDir})" -d postgres | grep -q 1 ''; name = "postgres-test"; }; depends_on = { "pg1".condition = "process_healthy"; "pg2".condition = "process_healthy"; + "pg3".condition = "process_healthy"; }; }; }