3 makeNode = couchpkg: user: passwd:
6 { environment.systemPackages = with pkgs; [ jq ];
7 services.couchdb.enable = true;
8 services.couchdb.package = couchpkg;
9 services.couchdb.adminUser = user;
10 services.couchdb.adminPass = passwd;
12 testuser = "testadmin";
13 testpass = "cowabunga";
14 testlogin = "${testuser}:${testpass}@";
16 in import ./make-test-python.nix ({ pkgs, lib, ...}:
22 meta = with pkgs.lib.maintainers; {
27 couchdb3 = makeNode pkgs.couchdb3 testuser testpass;
31 curlJqCheck = login: action: path: jqexpr: result:
32 pkgs.writeScript "curl-jq-check-${action}-${path}.sh" ''
33 RESULT=$(curl -X ${action} http://${login}127.0.0.1:5984/${path} | jq -r '${jqexpr}')
35 if [ "$RESULT" != "${result}" ]; then
42 couchdb3.wait_for_unit("couchdb.service")
43 couchdb3.wait_until_succeeds(
44 "${curlJqCheck testlogin "GET" "" ".couchdb" "Welcome"}"
46 couchdb3.wait_until_succeeds(
47 "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "0"}"
49 couchdb3.succeed("${curlJqCheck testlogin "PUT" "foo" ".ok" "true"}")
51 "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "1"}"
54 "${curlJqCheck testlogin "DELETE" "foo" ".ok" "true"}"
57 "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "0"}"
60 "${curlJqCheck testlogin "GET" "_node/couchdb@127.0.0.1" ".couchdb" "Welcome"}"