mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-27 08:04:14 +00:00
4f0dadbf38
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
69 lines
2.0 KiB
Nix
69 lines
2.0 KiB
Nix
let
|
|
pgheroPort = 1337;
|
|
pgheroUser = "pghero";
|
|
pgheroPass = "pghero";
|
|
in
|
|
{ lib, ... }:
|
|
{
|
|
name = "pghero";
|
|
meta.maintainers = [ lib.maintainers.tie ];
|
|
|
|
nodes.machine =
|
|
{ config, ... }:
|
|
{
|
|
services.postgresql = {
|
|
enable = true;
|
|
# This test uses default peer authentication (socket and its directory is
|
|
# world-readably by default), so we essentially test that we can connect
|
|
# with DynamicUser= set.
|
|
ensureUsers = [
|
|
{
|
|
name = "pghero";
|
|
ensureClauses.superuser = true;
|
|
}
|
|
];
|
|
};
|
|
services.pghero = {
|
|
enable = true;
|
|
listenAddress = "[::]:${toString pgheroPort}";
|
|
settings = {
|
|
databases = {
|
|
postgres.url = "<%= ENV['POSTGRES_DATABASE_URL'] %>";
|
|
nulldb.url = "nulldb:///";
|
|
};
|
|
};
|
|
environment = {
|
|
PGHERO_USERNAME = pgheroUser;
|
|
PGHERO_PASSWORD = pgheroPass;
|
|
POSTGRES_DATABASE_URL = "postgresql:///postgres?host=/run/postgresql";
|
|
};
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
pgheroPort = ${toString pgheroPort}
|
|
pgheroUser = "${pgheroUser}"
|
|
pgheroPass = "${pgheroPass}"
|
|
|
|
pgheroUnauthorizedURL = f"http://localhost:{pgheroPort}"
|
|
pgheroBaseURL = f"http://{pgheroUser}:{pgheroPass}@localhost:{pgheroPort}"
|
|
|
|
def expect_http_code(node, code, url):
|
|
http_code = node.succeed(f"curl -s -o /dev/null -w '%{{http_code}}' '{url}'")
|
|
assert http_code.split("\n")[-1].strip() == code, \
|
|
f"expected HTTP status code {code} but got {http_code}"
|
|
|
|
machine.wait_for_unit("postgresql.service")
|
|
machine.wait_for_unit("pghero.service")
|
|
|
|
with subtest("requires HTTP Basic Auth credentials"):
|
|
expect_http_code(machine, "401", pgheroUnauthorizedURL)
|
|
|
|
with subtest("works with some databases being unavailable"):
|
|
expect_http_code(machine, "500", pgheroBaseURL + "/nulldb")
|
|
|
|
with subtest("connects to the PostgreSQL database"):
|
|
expect_http_code(machine, "200", pgheroBaseURL + "/postgres")
|
|
'';
|
|
}
|