Sha256: f18f0380484de82272a08c3c4f89fa65b36ad3bda9713729abd4d4fc14af1ea1

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

module Helpers
  module Connections

    def local_connection_with_auth(user, password)
      Etcdv3.new(endpoints: "http://#{local_url}", user: user, password: password)
    end

    def local_connection(endpoints="http://#{local_url}", allow_reconnect: true)
      Etcdv3.new(endpoints: endpoints, allow_reconnect: allow_reconnect)
    end

    def local_connection_with_timeout(timeout)
      Etcdv3.new(endpoints: "http://#{local_url}", command_timeout: timeout)
    end

    def local_connection_with_namespace(namespace)
      Etcdv3.new(endpoints: "http://#{local_url}", namespace: namespace)
    end

    def local_stub(interface, timeout=nil)
      interface.new(local_url, :this_channel_is_insecure, timeout, {})
    end

    def local_namespace_stub(interface, timeout=nil, namespace)
      interface.new(local_url, :this_channel_is_insecure, timeout, namespace, {})
    end

    def local_url
      "127.0.0.1:#{port}"
    end

    def full_local_url
      "http://#{local_url}"
    end

    def port
      ENV.fetch('ETCD_TEST_PORT', 2379).to_i
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
etcdv3-0.11.4 spec/helpers/connections.rb
etcdv3-0.11.3 spec/helpers/connections.rb