File: no_server_available_spec.rb

package info (click to toggle)
ruby-mongo 2.21.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 14,764 kB
  • sloc: ruby: 108,806; makefile: 5; sh: 2
file content (35 lines) | stat: -rw-r--r-- 962 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true
# rubocop:todo all

require 'lite_spec_helper'

describe Mongo::Error::NoServerAvailable do
  describe 'message' do
    let(:selector) do
      Mongo::ServerSelector::Primary.new
    end

    let(:cluster) do
      Mongo::Cluster.new(['127.0.0.1:27017'],
        Mongo::Monitoring.new, monitoring_io: false)
    end

    let(:error) do
      Mongo::Error::NoServerAvailable.new(selector, cluster)
    end

    it 'is correct' do
      expect(error.message).to eq('No primary server is available in cluster: #<Cluster topology=Unknown[127.0.0.1:27017] servers=[#<Server address=127.0.0.1:27017 UNKNOWN NO-MONITORING>]> with timeout=30, LT=0.015')
    end

    context 'when cluster is nil' do
      let(:error) do
        Mongo::Error::NoServerAvailable.new(selector, nil)
      end

      it 'is correct' do
        expect(error.message).to eq('No primary server is available with timeout=30, LT=0.015')
      end
    end
  end
end