2020-04-04 11:20:03 +02:00
|
|
|
let
|
|
|
|
makeNode = couchpkg: user: passwd:
|
|
|
|
{ pkgs, ... } :
|
|
|
|
|
2023-04-30 16:26:16 +02:00
|
|
|
{ environment.systemPackages = [ pkgs.jq ];
|
2020-04-04 11:20:03 +02:00
|
|
|
services.couchdb.enable = true;
|
|
|
|
services.couchdb.package = couchpkg;
|
|
|
|
services.couchdb.adminUser = user;
|
|
|
|
services.couchdb.adminPass = passwd;
|
|
|
|
};
|
|
|
|
testuser = "testadmin";
|
|
|
|
testpass = "cowabunga";
|
|
|
|
testlogin = "${testuser}:${testpass}@";
|
2023-04-30 16:26:16 +02:00
|
|
|
in
|
|
|
|
import ./make-test-python.nix ({ pkgs, lib, ...}:
|
2017-11-19 17:36:47 +01:00
|
|
|
{
|
|
|
|
name = "couchdb";
|
2023-04-30 16:26:16 +02:00
|
|
|
meta.maintainers = [ ];
|
2017-11-19 17:36:47 +01:00
|
|
|
|
|
|
|
nodes = {
|
2020-04-04 11:20:03 +02:00
|
|
|
couchdb3 = makeNode pkgs.couchdb3 testuser testpass;
|
2017-11-19 17:36:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
testScript = let
|
2020-04-04 11:20:03 +02:00
|
|
|
curlJqCheck = login: action: path: jqexpr: result:
|
2017-11-19 17:36:47 +01:00
|
|
|
pkgs.writeScript "curl-jq-check-${action}-${path}.sh" ''
|
2020-04-04 11:20:03 +02:00
|
|
|
RESULT=$(curl -X ${action} http://${login}127.0.0.1:5984/${path} | jq -r '${jqexpr}')
|
2017-11-19 17:36:47 +01:00
|
|
|
echo $RESULT >&2
|
|
|
|
if [ "$RESULT" != "${result}" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
in ''
|
2019-11-06 20:53:18 +01:00
|
|
|
start_all()
|
|
|
|
|
2020-04-04 11:20:03 +02:00
|
|
|
couchdb3.wait_for_unit("couchdb.service")
|
|
|
|
couchdb3.wait_until_succeeds(
|
|
|
|
"${curlJqCheck testlogin "GET" "" ".couchdb" "Welcome"}"
|
|
|
|
)
|
|
|
|
couchdb3.wait_until_succeeds(
|
|
|
|
"${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "0"}"
|
|
|
|
)
|
|
|
|
couchdb3.succeed("${curlJqCheck testlogin "PUT" "foo" ".ok" "true"}")
|
|
|
|
couchdb3.succeed(
|
|
|
|
"${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "1"}"
|
|
|
|
)
|
|
|
|
couchdb3.succeed(
|
|
|
|
"${curlJqCheck testlogin "DELETE" "foo" ".ok" "true"}"
|
|
|
|
)
|
|
|
|
couchdb3.succeed(
|
|
|
|
"${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "0"}"
|
2019-11-06 20:53:18 +01:00
|
|
|
)
|
2021-12-08 17:57:00 +01:00
|
|
|
couchdb3.succeed(
|
|
|
|
"${curlJqCheck testlogin "GET" "_node/couchdb@127.0.0.1" ".couchdb" "Welcome"}"
|
|
|
|
)
|
2017-11-19 17:36:47 +01:00
|
|
|
'';
|
|
|
|
})
|