Skip to content

Commit

Permalink
Merge pull request #16224 from CaojiamingAlan/expose_isOptsWithFromKe…
Browse files Browse the repository at this point in the history
…y_and_isOptsWithPrefix

expose op.isOptsWithFromKey and op.isOptsWithPrefix
  • Loading branch information
ahrtr authored Jul 15, 2023
2 parents 882edb3 + 06579d9 commit ff411f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions client/v3/op.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
12 changes: 8 additions & 4 deletions client/v3/op_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

0 comments on commit ff411f5

Please sign in to comment.