mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 14:08:20 +00:00
Return generic result for get operations that includes error messages
This commit is contained in:
parent
4695060d75
commit
f1a7376e0a
27 changed files with 83 additions and 53 deletions
|
@ -26,9 +26,8 @@ event zeek_init() {
|
|||
print "erase result", res;
|
||||
|
||||
local res2 = Storage::get(b, key, F);
|
||||
if ( ! res2 as bool ) {
|
||||
print "get result, got empty result";
|
||||
}
|
||||
if ( res2?$error )
|
||||
print "get result", res2$error;
|
||||
|
||||
Storage::close_backend(b);
|
||||
}
|
||||
|
|
|
@ -17,8 +17,11 @@ global key: string = "key1234";
|
|||
global value: string = "value7890";
|
||||
|
||||
event check_removed() {
|
||||
# This should return an error from the sqlite backend that there aren't any more
|
||||
# rows available.
|
||||
local res2 = Storage::get(backend, key, F);
|
||||
print "get result", res2;
|
||||
if ( res2?$error )
|
||||
print "get result", res2$error;
|
||||
|
||||
Storage::close_backend(backend);
|
||||
terminate();
|
||||
|
@ -36,7 +39,8 @@ event setup_test() {
|
|||
|
||||
local res2 = Storage::get(backend, key, F);
|
||||
print "get result", res2;
|
||||
print "get result same as inserted", value == (res2 as string);
|
||||
if ( res2?$val )
|
||||
print "get result same as inserted", value == (res2$val as string);
|
||||
|
||||
schedule 5 secs { check_removed() };
|
||||
}
|
||||
|
|
|
@ -25,7 +25,8 @@ event zeek_init() {
|
|||
|
||||
local res2 = Storage::get(b, key, F);
|
||||
print "get result", res2;
|
||||
print "get result same as inserted", value == (res2 as string);
|
||||
if ( res2?$val )
|
||||
print "get result same as inserted", value == (res2$val as string);
|
||||
|
||||
Storage::close_backend(b);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ event zeek_init() {
|
|||
|
||||
when [b, key, value] ( local res2 = Storage::get(b, key) ) {
|
||||
print "get result", res2;
|
||||
print "get result same as inserted", value == (res2 as string);
|
||||
if ( res2?$val )
|
||||
print "get result same as inserted", value == (res2$val as string);
|
||||
|
||||
Storage::close_backend(b);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@ event zeek_init() {
|
|||
|
||||
when [b, key, value] ( local res2 = Storage::get(b, key) ) {
|
||||
print "get result", res2;
|
||||
print "get result same as inserted", value == (res2 as string);
|
||||
if ( res2?$val )
|
||||
print "get result same as inserted", value == (res2$val as string);
|
||||
|
||||
Storage::close_backend(b);
|
||||
|
||||
|
|
|
@ -47,7 +47,8 @@ event setup_test() {
|
|||
|
||||
local res2 = Storage::get(b, key, F);
|
||||
print "get result", res2;
|
||||
print "get result same as inserted", value == (res2 as string);
|
||||
if ( res2?$val )
|
||||
print "get result same as inserted", value == (res2$val as string);
|
||||
|
||||
schedule 5 secs { check_removed() };
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ event zeek_init() {
|
|||
|
||||
local res2 = Storage::get(b, key, F);
|
||||
print "get result", res2;
|
||||
print "get result same as inserted", value == (res2 as string);
|
||||
if ( res2?$val )
|
||||
print "get result same as inserted", value == (res2$val as string);
|
||||
|
||||
local value2 = "value5678";
|
||||
res = Storage::put(b, [$key=key, $value=value2, $overwrite=T, $async_mode=F]);
|
||||
|
@ -43,7 +44,8 @@ event zeek_init() {
|
|||
|
||||
res2 = Storage::get(b, key, F);
|
||||
print "get result", res2;
|
||||
print "get result same as inserted after overwrite", value == (res2 as string);
|
||||
if ( res2?$val )
|
||||
print "get result same as inserted", value2 == (res2$val as string);
|
||||
|
||||
Storage::close_backend(b);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ event zeek_init() {
|
|||
|
||||
when [b, key, value] ( local res2 = Storage::get(b, key) ) {
|
||||
print "get result", res2;
|
||||
print "get result same as inserted", value == (res2 as string);
|
||||
if ( res2?$val )
|
||||
print "get result same as inserted", value == (res2$val as string);
|
||||
|
||||
Storage::close_backend(b);
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@ event zeek_init() {
|
|||
|
||||
when [b, key, value] ( local get_res = Storage::get(b, key) ) {
|
||||
print "get result", get_res;
|
||||
print "get result same as inserted", value == (get_res as string);
|
||||
if ( get_res?$val )
|
||||
print "get result same as inserted", value == (get_res$val as string);
|
||||
|
||||
when [b] ( local close_res = Storage::close_backend(b, T) ) {
|
||||
print "closed succesfully";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue