diff options
author | Jiale Zhi <vipcalio@gmail.com> | 2013-10-29 11:26:14 -0700 |
---|---|---|
committer | Jiale Zhi <vipcalio@gmail.com> | 2013-10-29 11:26:14 -0700 |
commit | b4f8a86cd6ea00c13c7604c959c2f993e5e4e2cb (patch) | |
tree | 7eb7c64e5d99b43a6fed79924c3787602fa1df4e /t | |
parent | 5399f7514c90c3a332229efd15264655dafc366a (diff) | |
download | lua-resty-cookie-b4f8a86cd6ea00c13c7604c959c2f993e5e4e2cb.tar.gz lua-resty-cookie-b4f8a86cd6ea00c13c7604c959c2f993e5e4e2cb.tar.bz2 lua-resty-cookie-b4f8a86cd6ea00c13c7604c959c2f993e5e4e2cb.zip |
Add test cases for empty value and no cookie header
Diffstat (limited to 't')
-rw-r--r-- | t/sanity.t | 55 |
1 files changed, 53 insertions, 2 deletions
@@ -5,7 +5,7 @@ use Cwd qw(cwd); repeat_each(2); -plan tests => repeat_each() * (blocks() * 2); +plan tests => repeat_each() * (blocks() * 2 + 1); my $pwd = cwd(); @@ -16,7 +16,7 @@ our $HttpConfig = qq{ $ENV{TEST_NGINX_RESOLVER} = '8.8.8.8'; -no_long_string(); +#no_long_string(); log_level('debug'); @@ -76,3 +76,54 @@ Cookie: SID=31d4d96e407aad42; lang=en-US --- response_body lang => en-US + +=== TEST 3: no cookie header +--- 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 +--- error_log +no cookie found in current request +--- response_body + + +=== TEST 4: empty value +--- 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= +--- response_body +SID => + + |