! Copyright (C) 2010 John Benediktsson ! See http://factorcode.org/license.txt for BSD license USING: calendar math math.functions memcached memcached.private kernel sequences threads tools.test ; IN: memcached.tests : not-found? ( quot -- ) [ "not found" = ] must-fail-with ; ! test version [ t ] [ [ m/version ] with-memcached length 0 > ] unit-test ! test simple set get [ "valuex" "x" m/set ] with-memcached [ "valuex" ] [ [ "x" m/get ] with-memcached ] unit-test ! test flush [ "valuex" "x" m/set "valuey" "y" m/set ] with-memcached [ "valuex" ] [ [ "x" m/get ] with-memcached ] unit-test [ "valuey" ] [ [ "y" m/get ] with-memcached ] unit-test [ m/flush ] with-memcached [ [ "x" m/get ] with-memcached ] not-found? [ [ "y" m/get ] with-memcached ] not-found? ! test noop [ m/noop ] with-memcached ! test delete [ "valuex" "x" m/set ] with-memcached [ "valuex" ] [ [ "x" m/get ] with-memcached ] unit-test [ "x" m/delete ] with-memcached [ [ "x" m/get ] with-memcached ] not-found? ! test replace [ [ "x" m/get ] with-memcached ] not-found? [ [ "ex" "x" m/replace ] with-memcached ] not-found? [ "ex" "x" m/add ] with-memcached [ "ex" ] [ [ "x" m/get ] with-memcached ] unit-test [ "ex2" "x" m/replace ] with-memcached [ "ex2" ] [ [ "x" m/get ] with-memcached ] unit-test [ m/flush ] with-memcached ! test incr [ 0 ] [ [ "x" m/incr ] with-memcached ] unit-test [ 1 ] [ [ "x" m/incr ] with-memcached ] unit-test [ 212 ] [ [ 211 "x" m/incr-val ] with-memcached ] unit-test [ 8589934804 ] [ [ 2 33 ^ "x" m/incr-val ] with-memcached ] unit-test [ m/flush ] with-memcached ! test decr [ "5" "x" m/set ] with-memcached [ 4 ] [ [ "x" m/decr ] with-memcached ] unit-test [ 0 ] [ [ 211 "x" m/decr-val ] with-memcached ] unit-test ! test timebombed flush [ m/flush ] with-memcached [ [ "x" m/get ] with-memcached ] not-found? [ "valuex" "x" m/set ] with-memcached [ "valuex" ] [ [ "x" m/get ] with-memcached ] unit-test [ 2 m/flush-later ] with-memcached [ "valuex" ] [ [ "x" m/get ] with-memcached ] unit-test 3 seconds sleep [ [ "x" m/get ] with-memcached ] not-found? ! test append [ "some" "x" m/set ] with-memcached [ "thing" "x" m/append ] with-memcached [ "something" ] [ [ "x" m/get ] with-memcached ] unit-test [ m/flush ] with-memcached ! test prepend [ "some" "x" m/set ] with-memcached [ "thing" "x" m/prepend ] with-memcached [ "thingsome" ] [ [ "x" m/get ] with-memcached ] unit-test [ m/flush ] with-memcached