-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java: Add SETRANGE
command.
#1235
Changes from all commits
5a93bc4
5075877
8298cb2
a7e9c2c
7906e36
163859d
1769fd5
7568dea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,6 +144,7 @@ enum RequestType { | |
RPushX = 102; | ||
LPushX = 103; | ||
ZMScore = 104; | ||
SetRange = 107; | ||
} | ||
|
||
message Command { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,7 @@ | |
import static redis_request.RedisRequestOuterClass.RequestType.SMembers; | ||
import static redis_request.RedisRequestOuterClass.RequestType.SRem; | ||
import static redis_request.RedisRequestOuterClass.RequestType.Select; | ||
import static redis_request.RedisRequestOuterClass.RequestType.SetRange; | ||
import static redis_request.RedisRequestOuterClass.RequestType.SetString; | ||
import static redis_request.RedisRequestOuterClass.RequestType.Strlen; | ||
import static redis_request.RedisRequestOuterClass.RequestType.TTL; | ||
|
@@ -977,6 +978,32 @@ public void strlen_returns_success() { | |
assertEquals(value, payload); | ||
} | ||
|
||
@SneakyThrows | ||
@Test | ||
public void setrange_returns_success() { | ||
// setup | ||
String key = "testKey"; | ||
int offset = 42; | ||
String str = "pewpew"; | ||
String[] arguments = new String[] {key, Integer.toString(offset), str}; | ||
Long value = 10L; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor: value -> responseValue (value is confusing in the key-value context) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are 99 tests in this file and almost all of them have variable named "value". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
CompletableFuture<Long> testResponse = new CompletableFuture<>(); | ||
testResponse.complete(value); | ||
|
||
// match on protobuf request | ||
when(commandManager.<Long>submitNewCommand(eq(SetRange), eq(arguments), any())) | ||
.thenReturn(testResponse); | ||
|
||
// exercise | ||
CompletableFuture<Long> response = service.setrange(key, offset, str); | ||
Long payload = response.get(); | ||
|
||
// verify | ||
assertEquals(testResponse, response); | ||
assertEquals(value, payload); | ||
} | ||
|
||
@SneakyThrows | ||
@Test | ||
public void hget_success() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
key
holds a value that is not a string, an error is returned.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not document error cases for all commands to keep docs easy.
This comment is applicable to all commands - do you want to add it to a common place? readme?