Sha256: f4fc35ca8b9916c2de2be9894ff760297303dfb8a8afbfd27de77b002a153578

Contents?: true

Size: 1.68 KB

Versions: 11

Compression:

Stored size: 1.68 KB

Contents

require 'spec_helper'

describe Etcdv3::Lease do

  let(:stub) { local_stub(Etcdv3::Lease, 5) }

  it_should_behave_like "a method with a GRPC timeout", described_class, :lease_grant, :lease_grant, 10
  describe '#lease_grant' do
    subject { stub.lease_grant(10) }
    it 'grants lease' do
      expect(subject).to be_an_instance_of(Etcdserverpb::LeaseGrantResponse)
      expect(subject['ID']).to_not be_nil
    end
  end

  describe '#lease_revoke' do
    let(:id) { stub.lease_grant(60)['ID'] }
    subject { stub.lease_revoke(id) }
    it { is_expected.to be_an_instance_of(Etcdserverpb::LeaseRevokeResponse) }

    it 'raises a GRPC:DeadlineExceeded if the request takes too long' do
      stub = local_stub(Etcdv3::Lease, 0)
      expect { stub.lease_revoke(id) }.to raise_error(GRPC::DeadlineExceeded)
    end
  end

  describe '#lease_keep_alive_once' do
    let(:id) { stub.lease_grant(60)['ID'] }
    subject { stub.lease_keep_alive_once(id) }
    it { is_expected.to be_an_instance_of(Etcdserverpb::LeaseKeepAliveResponse) }
    it 'raises a GRPC:DeadlineExceeded if the request takes too long' do
      stub = local_stub(Etcdv3::Lease, 0)
      expect { stub.lease_keep_alive_once(id) }.to raise_error(GRPC::DeadlineExceeded)
    end
  end

  describe '#lease_ttl' do
    let(:stub) { local_stub(Etcdv3::Lease, 1) }
    let(:lease_id) { stub.lease_grant(10)['ID'] }
    subject { stub.lease_ttl(lease_id) }
    it { is_expected.to be_an_instance_of(Etcdserverpb::LeaseTimeToLiveResponse) }

    it 'raises a GRPC:DeadlineExceeded if the request takes too long' do
      stub = local_stub(Etcdv3::Lease, 0)
      expect { stub.lease_ttl(lease_id) }.to raise_error(GRPC::DeadlineExceeded)
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/spec/etcdv3/lease_spec.rb
etcdv3-0.11.6 spec/etcdv3/lease_spec.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/spec/etcdv3/lease_spec.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/spec/etcdv3/lease_spec.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/spec/etcdv3/lease_spec.rb
etcdv3-0.11.5 spec/etcdv3/lease_spec.rb
etcdv3-0.11.4 spec/etcdv3/lease_spec.rb
etcdv3-0.11.3 spec/etcdv3/lease_spec.rb
etcdv3-0.10.2 spec/etcdv3/lease_spec.rb
etcdv3-0.10.1 spec/etcdv3/lease_spec.rb
etcdv3-0.9.0 spec/etcdv3/lease_spec.rb