Sha256: b383f9b3a89c8c69f06023208202b035ccda6f1aa4af86b6ac8c293cbadf504a

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

describe Etcd::Client do

  let(:client) do
    Etcd.client
  end

  it 'should return the leader address' do
    expect(client.leader).to_not be_nil
  end

  it '#machines' do
    expect(client.machines).to include('http://127.0.0.1:4001')
  end

  it '#version' do
    expect(client.version).to match(/^etcd v?0\.\d+\.\d+(\+git)?/)
  end

  it '#version_prefix' do
    expect(client.version_prefix).to eq('/v2')
  end

  context '#api_execute' do
    it 'should raise exception when non http methods are passed' do
      expect do
        client.api_execute('/v2/keys/x', :do)
      end.to raise_error
    end

    it 'should redirect api request when allow_redirect is set' do
      key = random_key
      value = uuid.generate
      rd_client = Etcd.client host: 'localhost', port: 4003
      resp = rd_client.set(key, value: value)
      resp.node.key.should eql key
      resp.node.value.should eql value
      client.get(key).value.should eql resp.value
    end
  end

  context '#http header based metadata' do
    before(:all) do
      key = random_key
      value = uuid.generate
      @response = Etcd.client.set(key, value: value)
    end

    it '#etcd_index' do
      expect(@response.etcd_index).to_not be_nil
    end

    it '#raft_index' do
      expect(@response.raft_index).to_not be_nil
    end

    it '#raft_term' do
      expect(@response.raft_term).to_not be_nil
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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