;; This set of unit tests assumes that the memcached executable is in ;; the current PATH. (import scheme (chicken base) (chicken process) (chicken process-context posix) memcached test) (if (zero? (current-user-id)) (if (not (zero? (system "memcached -u chicken -d"))) (exit 1)) (if (not (zero? (system "memcached -d"))) (exit 1))) (sleep 3) (test-group "cas test" (with-server-connection h "localhost" 11211 (let ((counter 1)) (let ((success (set h "counter" counter))) (test-assert success) (let* ((res (car (gets h (list "counter")))) (cas-unique (cadddr res))) (test counter (caddr res)) (let* ((counter1 (cas h "counter" (+ counter 1) cas-unique)) (counter2 (get h "counter"))) (test counter2 (+ 1 counter)) )) )) )) (test-group "append/prepend test" (with-server-connection h "localhost" 11211 (let ((foo 4)) (let ((success (set h "foo" foo))) (test-assert success) (let ((success (append-to h "foo" 5))) (test-assert success) (test 45 (get h "foo")) )) )) ) (test-group "stats test" (with-server-connection h "localhost" 11211 (let ((data (stats h ))) (test-assert (and (assoc 'pid data) (assoc 'time data) (assoc 'version data)))))) (test-group "set/get test" (with-server-connection h "localhost" 11211 (let ((foo 4)) (let ((success (set h "foo" foo))) (test-assert success) (let ((foo1 (get h "foo"))) (test foo foo1)) (let ((foo2 (get h "bar"))) (test-assert (not foo2))) )))) (system "killall -SIGKILL memcached") (test-exit)