Sha256: 3e120b11dd4cc4baf4724c872ddce47a4287daeb10e4315b5db338297ca9343a
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
# Encoding: utf-8 require 'spec_helper' describe "Etcd test_and_set" do let(:client) do Etcd.client end it "should pass when prev value is correct" do key = random_key(2) old_value = uuid.generate new_value = uuid.generate client.set(key, old_value) client.test_and_set(key, new_value, old_value) expect(client.get(key).value).to eq(new_value) end it "should fail when prev value is incorrect" do key = random_key(2) value = uuid.generate client.set(key, value) expect{ client.test_and_set(key, 10, 2)}.to raise_error(Etcd::TestFailed) end it "#create should succeed when the key is absent and update should fail" do key = random_key(2) value = uuid.generate expect { client.update(key, value) }.to raise_error expect { client.create(key, value) }.to_not raise_error expect(client.get(key).value).to eq(value) end it "#create should fail when the key is present and update should succeed" do key = random_key(2) value = uuid.generate client.set(key, 1) expect { client.create(key, value) }.to raise_error expect { client.update(key, value) }.to_not raise_error end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
etcd-0.2.0.alpha | spec/etcd/test_and_set_spec.rb |