2 makeNode = couchpkg: user: passwd:
5 { environment.systemPackages = [ pkgs.jq ];
6 services.couchdb.enable = true;
7 services.couchdb.package = couchpkg;
8 services.couchdb.adminUser = user;
9 services.couchdb.adminPass = passwd;
11 testuser = "testadmin";
12 testpass = "cowabunga";
13 testlogin = "${testuser}:${testpass}@";
15 import ./make-test-python.nix ({ pkgs, lib, ...}:
18 meta.maintainers = [ ];
21 couchdb3 = makeNode pkgs.couchdb3 testuser testpass;
25 curlJqCheck = login: action: path: jqexpr: result:
26 pkgs.writeScript "curl-jq-check-${action}-${path}.sh" ''
27 RESULT=$(curl -X ${action} http://${login}127.0.0.1:5984/${path} | jq -r '${jqexpr}')
29 if [ "$RESULT" != "${result}" ]; then
36 couchdb3.wait_for_unit("couchdb.service")
37 couchdb3.wait_until_succeeds(
38 "${curlJqCheck testlogin "GET" "" ".couchdb" "Welcome"}"
40 couchdb3.wait_until_succeeds(
41 "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "0"}"
43 couchdb3.succeed("${curlJqCheck testlogin "PUT" "foo" ".ok" "true"}")
45 "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "1"}"
48 "${curlJqCheck testlogin "DELETE" "foo" ".ok" "true"}"
51 "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "0"}"
54 "${curlJqCheck testlogin "GET" "_node/couchdb@127.0.0.1" ".couchdb" "Welcome"}"