-
-
Save dminuoso/4b23c4c5636b3232b55b79a10d279110 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let nixpkgs = import <nixpkgs> {}; | |
nixos-lib = import (<nixpkgs> + "/nixos/lib") {}; | |
in | |
nixos-lib.runTest { | |
nodes.db = { lib, ... }: { | |
config = { | |
services.postgresql = { | |
enable = true; | |
settings.log_statement = "all"; | |
authentication = '' | |
local mydb myuser peer | |
''; | |
ensureDatabases = [ "mydb" ]; | |
ensureUsers = [{ | |
name = "myuser"; | |
ensurePermissions = { | |
"ALL TABLES IN SCHEMA public" = "ALL PRIVILEGES"; | |
}; | |
}]; | |
}; | |
users.groups."mygroup" = {}; | |
users.users."myuser".isNormalUser = true; | |
users.users."myuser".group = "mygroup"; | |
}; | |
}; | |
name = "Test if database works"; | |
hostPkgs = nixpkgs; | |
testScript = '' | |
db.wait_for_unit("postgresql.service") | |
db.succeed("sudo -u myuser psql -d mydb -c \"SELECT VERSION()\"") | |
''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment