MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / TestAssertStringReply

Function TestAssertStringReply

tests/modules/basics.c:385–408  ·  view source on GitHub ↗

Return 1 if the reply matches the specified string, otherwise log errors * in the server log and return 0. */

Source from the content-addressed store, hash-verified

383/* Return 1 if the reply matches the specified string, otherwise log errors
384 * in the server log and return 0. */
385int TestAssertStringReply(RedisModuleCtx *ctx, RedisModuleCallReply *reply, char *str, size_t len) {
386 RedisModuleString *mystr, *expected;
387
388 if (RedisModule_CallReplyType(reply) == REDISMODULE_REPLY_ERROR) {
389 RedisModule_Log(ctx,"warning","Test error reply: %s",
390 RedisModule_CallReplyStringPtr(reply, NULL));
391 return 0;
392 } else if (RedisModule_CallReplyType(reply) != REDISMODULE_REPLY_STRING) {
393 RedisModule_Log(ctx,"warning","Unexpected reply type %d",
394 RedisModule_CallReplyType(reply));
395 return 0;
396 }
397 mystr = RedisModule_CreateStringFromCallReply(reply);
398 expected = RedisModule_CreateString(ctx,str,len);
399 if (RedisModule_StringCompare(mystr,expected) != 0) {
400 const char *mystr_ptr = RedisModule_StringPtrLen(mystr,NULL);
401 const char *expected_ptr = RedisModule_StringPtrLen(expected,NULL);
402 RedisModule_Log(ctx,"warning",
403 "Unexpected string reply '%s' (instead of '%s')",
404 mystr_ptr, expected_ptr);
405 return 0;
406 }
407 return 1;
408}
409
410/* Return 1 if the reply matches the specified integer, otherwise log errors
411 * in the server log and return 0. */

Callers 1

TestBasicsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected