at 23.11-pre 1.7 kB view raw
1let 2 makeNode = couchpkg: user: passwd: 3 { pkgs, ... } : 4 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; 10 }; 11 testuser = "testadmin"; 12 testpass = "cowabunga"; 13 testlogin = "${testuser}:${testpass}@"; 14in 15import ./make-test-python.nix ({ pkgs, lib, ...}: 16{ 17 name = "couchdb"; 18 meta.maintainers = [ ]; 19 20 nodes = { 21 couchdb3 = makeNode pkgs.couchdb3 testuser testpass; 22 }; 23 24 testScript = let 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}') 28 echo $RESULT >&2 29 if [ "$RESULT" != "${result}" ]; then 30 exit 1 31 fi 32 ''; 33 in '' 34 start_all() 35 36 couchdb3.wait_for_unit("couchdb.service") 37 couchdb3.wait_until_succeeds( 38 "${curlJqCheck testlogin "GET" "" ".couchdb" "Welcome"}" 39 ) 40 couchdb3.wait_until_succeeds( 41 "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "0"}" 42 ) 43 couchdb3.succeed("${curlJqCheck testlogin "PUT" "foo" ".ok" "true"}") 44 couchdb3.succeed( 45 "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "1"}" 46 ) 47 couchdb3.succeed( 48 "${curlJqCheck testlogin "DELETE" "foo" ".ok" "true"}" 49 ) 50 couchdb3.succeed( 51 "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "0"}" 52 ) 53 couchdb3.succeed( 54 "${curlJqCheck testlogin "GET" "_node/couchdb@127.0.0.1" ".couchdb" "Welcome"}" 55 ) 56 ''; 57})