File: unsupported_option_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 (57 lines) | stat: -rw-r--r-- 2,057 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# frozen_string_literal: true
# rubocop:todo all

require 'spec_helper'

describe Mongo::Error::UnsupportedOption do
  describe '.hint_error' do
    context 'with no options' do
      let(:error) { described_class.hint_error }

      it 'creates an error with a default message' do
        expect(error.message).to eq(
          "The MongoDB server handling this request does not support the hint " \
          "option on this command. The hint option is supported on update commands " \
          "on MongoDB server versions 4.2 and later and on findAndModify and delete " \
          "commands on MongoDB server versions 4.4 and later"
        )
      end

      context 'with unacknowledged_write: true' do
        let(:error) { described_class.hint_error(unacknowledged_write: true) }

        it 'creates an error with a default unacknowledged writes message' do
          expect(error.message).to eq(
            "The hint option cannot be specified on an unacknowledged " \
            "write operation. Remove the hint option or perform this " \
            "operation with a write concern of at least { w: 1 }"
          )
        end
      end
    end
  end

  describe '.allow_disk_use_error' do
    let(:error) { described_class.allow_disk_use_error }

    it 'creates an error with a default message' do
      expect(error.message).to eq(
        "The MongoDB server handling this request does not support the allow_disk_use " \
        "option on this command. The allow_disk_use option is supported on find commands " \
        "on MongoDB server versions 4.4 and later"
      )
    end
  end

  describe '.commit_quorum_error' do
    let(:error) { described_class.commit_quorum_error }

    it 'creates an error with a default message' do
      expect(error.message).to eq(
        "The MongoDB server handling this request does not support the commit_quorum " \
        "option on this command. The commit_quorum option is supported on createIndexes commands " \
        "on MongoDB server versions 4.4 and later"
      )
    end
  end
end