-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add support for colon separator of keyspace:shard #2685
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
Changes from 3 commits
58ce6d8
9f3aaee
4e1eeab
bddf84a
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 |
|---|---|---|
|
|
@@ -2683,3 +2683,45 @@ func TestVTGateShowMetadataTwoShards(t *testing.T) { | |
| t.Errorf("shard %s not found in Values \n%+v", shard1, qr.Rows) | ||
| } | ||
| } | ||
|
|
||
| func TestParseKeyspaceOptionalShard(t *testing.T) { | ||
| testcases := []struct { | ||
| keyspaceShard string | ||
| keyspace string | ||
| shard string | ||
| }{{ | ||
| keyspaceShard: "ks", | ||
| keyspace: "ks", | ||
| shard: "", | ||
| }, { | ||
| keyspaceShard: "/-80", | ||
|
Contributor
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. I suggest that we remove the test cases where one of the parts is empty. IMO this is outside of the "specification" and therefore the behaviour for such an input should not be defined. But by having it in the test, we're implicitly defining it and making it part of our "specification". For example, we may consider to error on this input in the future. Therefore, I prefer if you delete this case and the cases |
||
| keyspace: "", | ||
| shard: "-80", | ||
| }, { | ||
| keyspaceShard: "ks/-80", | ||
| keyspace: "ks", | ||
| shard: "-80", | ||
| }, { | ||
| keyspaceShard: "ks/", | ||
| keyspace: "ks", | ||
| shard: "", | ||
| }, { | ||
| keyspaceShard: "ks:", | ||
| keyspace: "ks", | ||
| shard: "", | ||
| }, { | ||
| keyspaceShard: "ks:-80", | ||
| keyspace: "ks", | ||
| shard: "-80", | ||
| }, { | ||
| keyspaceShard: ":-80", | ||
| keyspace: "", | ||
| shard: "-80", | ||
| }} | ||
|
|
||
| for _, tcase := range testcases { | ||
| if keyspace, shard := parseKeyspaceOptionalShard(tcase.keyspaceShard); keyspace != tcase.keyspace || shard != tcase.shard { | ||
| t.Errorf("parseKeyspaceShard(%s): %s:%s, want %s:%s", tcase.keyspaceShard, keyspace, shard, tcase.keyspace, tcase.shard) | ||
| } | ||
| } | ||
| } | ||
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.
nit: Missing period in the last sentence after
/.