| 127 | } |
| 128 | |
| 129 | int TestUnlink(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { |
| 130 | RedisModule_AutoMemory(ctx); |
| 131 | REDISMODULE_NOT_USED(argv); |
| 132 | REDISMODULE_NOT_USED(argc); |
| 133 | |
| 134 | RedisModuleKey *k = RedisModule_OpenKey(ctx, RedisModule_CreateStringPrintf(ctx, "unlinked"), REDISMODULE_WRITE | REDISMODULE_READ); |
| 135 | if (!k) return failTest(ctx, "Could not create key"); |
| 136 | |
| 137 | if (REDISMODULE_ERR == RedisModule_StringSet(k, RedisModule_CreateStringPrintf(ctx, "Foobar"))) { |
| 138 | return failTest(ctx, "Could not set string value"); |
| 139 | } |
| 140 | |
| 141 | RedisModuleCallReply *rep = RedisModule_Call(ctx, "EXISTS", "c", "unlinked"); |
| 142 | if (!rep || RedisModule_CallReplyInteger(rep) != 1) { |
| 143 | return failTest(ctx, "Key does not exist before unlink"); |
| 144 | } |
| 145 | |
| 146 | if (REDISMODULE_ERR == RedisModule_UnlinkKey(k)) { |
| 147 | return failTest(ctx, "Could not unlink key"); |
| 148 | } |
| 149 | |
| 150 | rep = RedisModule_Call(ctx, "EXISTS", "c", "unlinked"); |
| 151 | if (!rep || RedisModule_CallReplyInteger(rep) != 0) { |
| 152 | return failTest(ctx, "Could not verify key to be unlinked"); |
| 153 | } |
| 154 | return RedisModule_ReplyWithSimpleString(ctx, "OK"); |
| 155 | } |
| 156 | |
| 157 | /* TEST.STRING.TRUNCATE -- Test truncating an existing string object. */ |
| 158 | int TestStringTruncate(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { |
nothing calls this directly
no test coverage detected