Skip to content

Commit

Permalink
Merge pull request #110 from davissp14/txn-del-fix
Browse files Browse the repository at this point in the history
Fixing bug that was preventing txn.del from working as expected
  • Loading branch information
davissp14 authored Dec 5, 2017
2 parents 9f04605 + 83618eb commit b437c0a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/etcdv3/kv/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def get(key, opts={})
end

# txn.del('key')
def del(key, opts={})
del_request(key, opts)
def del(key, range_end='')
del_request(key, range_end)
end

### Compare Operations
Expand Down
30 changes: 28 additions & 2 deletions spec/etcdv3/kv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,37 @@
end

describe '#transaction' do
context 'put' do
let!(:block) do
Proc.new do |txn|
txn.compare = [ txn.value('txn', :equal, 'value') ]
txn.success = [ txn.put('txn-test', 'success') ]
txn.failure = [ txn.put('txn-test', 'failed') ]
end
end
subject { stub.transaction(block) }
it { is_expected.to be_an_instance_of(Etcdserverpb::TxnResponse) }
end

context 'del' do
let!(:block) do
Proc.new do |txn|
txn.compare = [ txn.value('txn', :equal, 'value') ]
txn.success = [ txn.del('txn-one') ]
txn.failure = [ txn.del('txn-two') ]
end
end
subject { stub.transaction(block) }
it { is_expected.to be_an_instance_of(Etcdserverpb::TxnResponse) }
end
end

context 'get' do
let!(:block) do
Proc.new do |txn|
txn.compare = [ txn.value('txn', :equal, 'value') ]
txn.success = [ txn.put('txn-test', 'success') ]
txn.failure = [ txn.put('txn-test', 'failed') ]
txn.success = [ txn.get('txn-success') ]
txn.failure = [ txn.get('txn-failure') ]
end
end
subject { stub.transaction(block) }
Expand Down

0 comments on commit b437c0a

Please sign in to comment.