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

Function TestBasics

tests/modules/basics.c:442–487  ·  view source on GitHub ↗

TEST.BASICS -- Run all the tests. * Note: it is useful to run these tests from the module rather than TCL * since it's easier to check the reply types like that (make a distinction * between 0 and "0", etc. */

Source from the content-addressed store, hash-verified

440 * since it's easier to check the reply types like that (make a distinction
441 * between 0 and "0", etc. */
442int TestBasics(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
443 REDISMODULE_NOT_USED(argv);
444 REDISMODULE_NOT_USED(argc);
445
446 RedisModule_AutoMemory(ctx);
447 RedisModuleCallReply *reply;
448
449 /* Make sure the DB is empty before to proceed. */
450 T("dbsize","");
451 if (!TestAssertIntegerReply(ctx,reply,0)) goto fail;
452
453 T("ping","");
454 if (!TestAssertStringReply(ctx,reply,"PONG",4)) goto fail;
455
456 T("test.call","");
457 if (!TestAssertStringReply(ctx,reply,"OK",2)) goto fail;
458
459 T("test.ctxflags","");
460 if (!TestAssertStringReply(ctx,reply,"OK",2)) goto fail;
461
462 T("test.string.append","");
463 if (!TestAssertStringReply(ctx,reply,"foobar",6)) goto fail;
464
465 T("test.string.truncate","");
466 if (!TestAssertStringReply(ctx,reply,"OK",2)) goto fail;
467
468 T("test.unlink","");
469 if (!TestAssertStringReply(ctx,reply,"OK",2)) goto fail;
470
471 T("test.string.append.am","");
472 if (!TestAssertStringReply(ctx,reply,"foobar",6)) goto fail;
473
474 T("test.string.printf", "cc", "foo", "bar");
475 if (!TestAssertStringReply(ctx,reply,"Got 3 args. argv[1]: foo, argv[2]: bar",38)) goto fail;
476
477 T("test.notify", "");
478 if (!TestAssertStringReply(ctx,reply,"OK",2)) goto fail;
479
480 RedisModule_ReplyWithSimpleString(ctx,"ALL TESTS PASSED");
481 return REDISMODULE_OK;
482
483fail:
484 RedisModule_ReplyWithSimpleString(ctx,
485 "SOME TEST DID NOT PASS! Check server logs");
486 return REDISMODULE_OK;
487}
488
489int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
490 REDISMODULE_NOT_USED(argv);

Callers

nothing calls this directly

Calls 2

TestAssertIntegerReplyFunction · 0.85
TestAssertStringReplyFunction · 0.85

Tested by

no test coverage detected