Merge pull request #16224 from CaojiamingAlan/expose_isOptsWithFromKey_and_isOptsWithPrefix

expose op.isOptsWithFromKey and op.isOptsWithPrefix
This commit is contained in:
Benjamin Wang 2023-07-15 18:35:39 +01:00 committed by GitHub
commit ff411f517f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -124,6 +124,10 @@ func (op Op) IsKeysOnly() bool { return op.keysOnly }
// IsCountOnly returns whether countOnly is set.
func (op Op) IsCountOnly() bool { return op.countOnly }
func (op Op) IsOptsWithFromKey() bool { return op.isOptsWithFromKey }
func (op Op) IsOptsWithPrefix() bool { return op.isOptsWithPrefix }
// MinModRev returns the operation's minimum modify revision.
func (op Op) MinModRev() int64 { return op.minModRev }

View File

@ -78,24 +78,28 @@ func TestIsSortOptionValid(t *testing.T) {
func TestIsOptsWithPrefix(t *testing.T) {
optswithprefix := []OpOption{WithPrefix()}
if !IsOptsWithPrefix(optswithprefix) {
op := OpGet("key", optswithprefix...)
if !IsOptsWithPrefix(optswithprefix) || !op.IsOptsWithPrefix() {
t.Errorf("IsOptsWithPrefix = false, expected true")
}
optswithfromkey := []OpOption{WithFromKey()}
if IsOptsWithPrefix(optswithfromkey) {
op = OpGet("key", optswithfromkey...)
if IsOptsWithPrefix(optswithfromkey) || op.IsOptsWithPrefix() {
t.Errorf("IsOptsWithPrefix = true, expected false")
}
}
func TestIsOptsWithFromKey(t *testing.T) {
optswithfromkey := []OpOption{WithFromKey()}
if !IsOptsWithFromKey(optswithfromkey) {
op := OpGet("key", optswithfromkey...)
if !IsOptsWithFromKey(optswithfromkey) || !op.IsOptsWithFromKey() {
t.Errorf("IsOptsWithFromKey = false, expected true")
}
optswithprefix := []OpOption{WithPrefix()}
if IsOptsWithFromKey(optswithprefix) {
op = OpGet("key", optswithprefix...)
if IsOptsWithFromKey(optswithprefix) || op.IsOptsWithFromKey() {
t.Errorf("IsOptsWithFromKey = true, expected false")
}
}