Sha256: bb9d9deacf9d2cf61670beccaf9698c2cb2707fa4e3581d67a7306d86b9a491f

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true
# rubocop:todo all

require 'spec_helper'

# This test is for checking connectivity of the test client to the
# test cluster. In other words, it is a test that the test suite is
# configured correctly.
describe 'Client connectivity' do
  shared_examples_for 'is correctly configured' do
    it 'is configured with the correct database' do
      expect(client.options[:database]).to eq(SpecConfig.instance.test_db)
    end

    it 'has correct database in the cluster' do
      expect(client.cluster.options[:database]).to eq(SpecConfig.instance.test_db)
    end
  end

  context 'no auth' do
    let(:client) { ClientRegistry.instance.global_client('basic') }

    it_behaves_like 'is correctly configured'

    it 'connects and is usable' do
      resp = client.database.command(ping: 1)
      expect(resp).to be_a(Mongo::Operation::Result)
    end
  end

  context 'with auth' do
    let(:client) { ClientRegistry.instance.global_client('authorized') }

    it_behaves_like 'is correctly configured'

    it 'connects and is usable' do
      client['connectivity_spec'].insert_one(foo: 1)
      expect(client['connectivity_spec'].find(foo: 1).first['foo']).to eq(1)
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
mongo-2.21.0 spec/integration/client_connectivity_spec.rb
mongo-2.20.1 spec/integration/client_connectivity_spec.rb
mogno-2.20.0 spec/integration/client_connectivity_spec.rb
mogno-1.0.0 spec/integration/client_connectivity_spec.rb
mongo-2.20.0 spec/integration/client_connectivity_spec.rb
mongo-2.19.3 spec/integration/client_connectivity_spec.rb
mongo-2.19.2 spec/integration/client_connectivity_spec.rb
mongo-2.19.1 spec/integration/client_connectivity_spec.rb
mongo-2.19.0 spec/integration/client_connectivity_spec.rb