Sha256: 761d2a9bad437feb87d3e381ed9ae975538a547d05cd0d11fcacaaf6bc88ae94

Contents?: true

Size: 856 Bytes

Versions: 3

Compression:

Stored size: 856 Bytes

Contents

# Encoding: utf-8

require 'spec_helper'

describe 'Etcd watch' do

  let(:client) do
    Etcd.client
  end

  it 'without index, returns the value at a particular index' do
    key = random_key(4)
    value1 = uuid.generate
    value2 = uuid.generate

    index1 = client.create(key, value: value1).node.modifiedIndex
    index2 = client.test_and_set(key, value: value2, prevValue: value1).node.modifiedIndex

    expect(client.watch(key, index: index1).node.value).to eq(value1)
    expect(client.watch(key, index: index2).node.value).to eq(value2)
  end

  it 'with index, waits and return when the key is updated' do
    response = nil
    key = random_key
    value = uuid.generate
    thr = Thread.new do
      response = client.watch(key)
    end
    client.set(key, value: value)
    thr.join
    expect(response.node.value).to eq(value)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
etcd-0.2.2 spec/etcd/watch_spec.rb
etcd-0.2.1 spec/etcd/watch_spec.rb
etcd-0.2.0.beta.1 spec/etcd/watch_spec.rb