From 589602686c009bcc98c98994257bed90440c8388 Mon Sep 17 00:00:00 2001 From: Aapo Talvensaari Date: Wed, 17 May 2023 12:55:11 +0300 Subject: [PATCH] tests(edge-cases): adds edge cases to test that values are returned as they are set ### Summary See: FTI-5068 --- t/00-init_mdb.t | 157 +++++++++++++++++++++++++++- t/05-encrypt_and_find_plaintext.t | 164 +++++++++++++++++++++++++++++- 2 files changed, 317 insertions(+), 4 deletions(-) diff --git a/t/00-init_mdb.t b/t/00-init_mdb.t index ed623e48..e20c3794 100644 --- a/t/00-init_mdb.t +++ b/t/00-init_mdb.t @@ -32,7 +32,6 @@ __DATA__ location = /t { content_by_lua_block { local l = require("resty.lmdb") - ngx.say(l.set("test", "value")) ngx.say(l.get("test")) ngx.say(l.get("test_not_exist")) @@ -48,3 +47,159 @@ nil [error] [warn] [crit] + + + +=== TEST 2: single key edge cases set() / get() (16359) +--- http_config eval: $::HttpConfig +--- main_config eval: $::MainConfig +--- config + location = /t { + content_by_lua_block { + local l = require("resty.lmdb") + local v = ("a"):rep(16359) + l.set("a", v) + ngx.say(v == l.get("a")) + } + } +--- request +GET /t +--- response_body +true +--- no_error_log +[error] +[warn] +[crit] + + + +=== TEST 3: single key edge cases set() / get() (16360) +--- http_config eval: $::HttpConfig +--- main_config eval: $::MainConfig +--- config + location = /t { + content_by_lua_block { + local l = require("resty.lmdb") + local v = ("a"):rep(16360) + l.set("a", v) + ngx.say(v == l.get("a")) + } + } +--- request +GET /t +--- response_body +true +--- no_error_log +[error] +[warn] +[crit] + + + +=== TEST 4: single key edge cases set() / get() (16361) +--- http_config eval: $::HttpConfig +--- main_config eval: $::MainConfig +--- config + location = /t { + content_by_lua_block { + local l = require("resty.lmdb") + local v = ("a"):rep(16361) + l.set("a", v) + ngx.say(v == l.get("a")) + } + } +--- request +GET /t +--- response_body +true +--- no_error_log +[error] +[warn] +[crit] + + + +=== TEST 5: three keys key edge cases set() / get() (5442) +--- http_config eval: $::HttpConfig +--- main_config eval: $::MainConfig +--- config + location = /t { + content_by_lua_block { + local l = require("resty.lmdb") + local v = ("a"):rep(5442) + l.set("a", v) + l.set("b", v) + l.set("c", v) + ngx.say(v == l.get("a")) + ngx.say(v == l.get("b")) + ngx.say(v == l.get("c")) + } + } +--- request +GET /t +--- response_body +true +true +true +--- no_error_log +[error] +[warn] +[crit] + + + +=== TEST 6: three keys edge cases set() / get() (5443) +--- http_config eval: $::HttpConfig +--- main_config eval: $::MainConfig +--- config + location = /t { + content_by_lua_block { + local l = require("resty.lmdb") + local v = ("a"):rep(5443) + l.set("a", v) + l.set("b", v) + l.set("c", v) + ngx.say(v == l.get("a")) + ngx.say(v == l.get("b")) + ngx.say(v == l.get("c")) + } + } +--- request +GET /t +--- response_body +true +true +true +--- no_error_log +[error] +[warn] +[crit] + + + +=== TEST 7: three keys edge cases set() / get() (5444) +--- http_config eval: $::HttpConfig +--- main_config eval: $::MainConfig +--- config + location = /t { + content_by_lua_block { + local l = require("resty.lmdb") + local v = ("a"):rep(5444) + l.set("a", v) + l.set("b", v) + l.set("c", v) + ngx.say(v == l.get("a")) + ngx.say(v == l.get("b")) + ngx.say(v == l.get("c")) + } + } +--- request +GET /t +--- response_body +true +true +true +--- no_error_log +[error] +[warn] +[crit] diff --git a/t/05-encrypt_and_find_plaintext.t b/t/05-encrypt_and_find_plaintext.t index 4f3f287f..9f6172ae 100644 --- a/t/05-encrypt_and_find_plaintext.t +++ b/t/05-encrypt_and_find_plaintext.t @@ -81,7 +81,163 @@ nil -=== TEST 2: clear using set() +=== TEST 2: single key edge cases set() / get() (16359) +--- http_config eval: $::HttpConfig +--- main_config eval: $::MainConfig +--- config + location = /t { + content_by_lua_block { + local l = require("resty.lmdb") + local v = ("a"):rep(16359) + l.set("a", v) + ngx.say(v == l.get("a")) + } + } +--- request +GET /t +--- response_body +true +--- no_error_log +[error] +[warn] +[crit] + + + +=== TEST 3: single key edge cases set() / get() (16360) +--- http_config eval: $::HttpConfig +--- main_config eval: $::MainConfig +--- config + location = /t { + content_by_lua_block { + local l = require("resty.lmdb") + local v = ("a"):rep(16360) + l.set("a", v) + ngx.say(v == l.get("a")) + } + } +--- request +GET /t +--- response_body +true +--- no_error_log +[error] +[warn] +[crit] + + + +=== TEST 4: single key edge cases set() / get() (16361) +--- http_config eval: $::HttpConfig +--- main_config eval: $::MainConfig +--- config + location = /t { + content_by_lua_block { + local l = require("resty.lmdb") + local v = ("a"):rep(16361) + l.set("a", v) + ngx.say(v == l.get("a")) + } + } +--- request +GET /t +--- response_body +true +--- no_error_log +[error] +[warn] +[crit] + + + +=== TEST 5: three keys key edge cases set() / get() (5442) +--- http_config eval: $::HttpConfig +--- main_config eval: $::MainConfig +--- config + location = /t { + content_by_lua_block { + local l = require("resty.lmdb") + local v = ("a"):rep(5442) + l.set("a", v) + l.set("b", v) + l.set("c", v) + ngx.say(v == l.get("a")) + ngx.say(v == l.get("b")) + ngx.say(v == l.get("c")) + } + } +--- request +GET /t +--- response_body +true +true +true +--- no_error_log +[error] +[warn] +[crit] + + + +=== TEST 6: three keys edge cases set() / get() (5443) +--- http_config eval: $::HttpConfig +--- main_config eval: $::MainConfig +--- config + location = /t { + content_by_lua_block { + local l = require("resty.lmdb") + local v = ("a"):rep(5443) + l.set("a", v) + l.set("b", v) + l.set("c", v) + ngx.say(v == l.get("a")) + ngx.say(v == l.get("b")) + ngx.say(v == l.get("c")) + } + } +--- request +GET /t +--- response_body +true +true +true +--- no_error_log +[error] +[warn] +[crit] + + + +=== TEST 7: three keys edge cases set() / get() (5444) +--- http_config eval: $::HttpConfig +--- main_config eval: $::MainConfig +--- config + location = /t { + content_by_lua_block { + local l = require("resty.lmdb") + local v = ("a"):rep(5444) + l.set("a", v) + l.set("b", v) + l.set("c", v) + ngx.say(v == l.get("a")) + ngx.say(v == l.get("b")) + ngx.say(v == l.get("c")) + } + } +--- request +GET /t +--- response_body +true +true +true +--- no_error_log +[error] +[warn] +[crit] + + + +=== TEST 8: clear using set() --- http_config eval: $::HttpConfig --- main_config eval: $::MainConfig --- config @@ -107,7 +263,7 @@ nil -=== TEST 3: db_drop() +=== TEST 9: db_drop() --- http_config eval: $::HttpConfig --- main_config eval: $::MainConfig --- config @@ -131,7 +287,9 @@ nil [warn] [crit] -=== TEST 4: simple set() / get() + + +=== TEST 10: simple set() / get() --- http_config eval: $::HttpConfig --- main_config eval: $::MainConfig1 --- config