diff options
author | Jiale Zhi <vipcalio@gmail.com> | 2013-10-28 17:46:31 -0700 |
---|---|---|
committer | Jiale Zhi <vipcalio@gmail.com> | 2013-10-28 17:46:31 -0700 |
commit | dfe1d93d735cd506276b89f8dbbcded393e4dac0 (patch) | |
tree | daa6b1bc175ffa7f31a8c25e9bdeef9dc394ea8d /t | |
parent | dfe29201044725d04c16ea6b50bc2e7f1893fd8e (diff) | |
download | lua-resty-cookie-dfe1d93d735cd506276b89f8dbbcded393e4dac0.tar.gz lua-resty-cookie-dfe1d93d735cd506276b89f8dbbcded393e4dac0.tar.bz2 lua-resty-cookie-dfe1d93d735cd506276b89f8dbbcded393e4dac0.zip |
Implement basic features
Diffstat (limited to 't')
-rw-r--r-- | t/sanity.t | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/t/sanity.t b/t/sanity.t new file mode 100644 index 0000000..c9d7262 --- /dev/null +++ b/t/sanity.t @@ -0,0 +1,78 @@ +# vim:set ft= ts=4 sw=4 et: + +use Test::Nginx::Socket; +use Cwd qw(cwd); + +repeat_each(2); + +plan tests => repeat_each() * (blocks() * 2); + +my $pwd = cwd(); + +our $HttpConfig = qq{ + lua_package_path "$pwd/lib/?.lua;;"; + lua_package_cpath "/usr/local/openresty-debug/lualib/?.so;/usr/local/openresty/lualib/?.so;;"; +}; + +$ENV{TEST_NGINX_RESOLVER} = '8.8.8.8'; + +no_long_string(); + +log_level('debug'); + +run_tests(); + +__DATA__ + +=== TEST 1: sanity +--- http_config eval: $::HttpConfig +--- config + location /t { + content_by_lua ' + local ck = require "resty.cookie" + local cookie, err = ck:new() + if not cookie then + ngx.log(ngx.ERR, err) + return + end + + local fields = cookie:get_all() + + for k, v in pairs(fields) do + ngx.say(k, " => ", v) + end + '; + } +--- request +GET /t +--- more_headers +Cookie: SID=31d4d96e407aad42; lang=en-US +--- response_body +SID => 31d4d96e407aad42 +lang => en-US + + + +=== TEST 2: sanity 2 +--- http_config eval: $::HttpConfig +--- config + location /t { + content_by_lua ' + local ck = require "resty.cookie" + local cookie, err = ck:new() + if not cookie then + ngx.log(ngx.ERR, err) + return + end + + local field = cookie:get("lang") + ngx.say("lang", " => ", field) + '; + } +--- request +GET /t +--- more_headers +Cookie: SID=31d4d96e407aad42; lang=en-US +--- response_body +lang => en-US + |