Sha256: ff1418c915a8503eb991811fa17ab51dd4d9eb8e547e4748f3a64c572fe983ae

Contents?: true

Size: 1.39 KB

Versions: 6

Compression:

Stored size: 1.39 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_stub_with_metadata(interface, timeout: nil, metadata: {})
      interface.new(local_url, :this_channel_is_insecure, timeout, metadata)
    end

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

    def local_namespace_stub_with_metadata(interface, timeout: nil, namespace:, metadata: {})
      interface.new(local_url, :this_channel_is_insecure, timeout, namespace, metadata)
    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

6 entries across 6 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/helpers/connections.rb
etcdv3-0.11.6 spec/helpers/connections.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/spec/helpers/connections.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/spec/helpers/connections.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/spec/helpers/connections.rb
etcdv3-0.11.5 spec/helpers/connections.rb