Sha256: cb3214c772d4940d0bec0493814dbe01a925a7f8f41b5c1b8464865ab6e6c990

Contents?: true

Size: 1.4 KB

Versions: 9

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true
# rubocop:todo all

module Mongo
  module CRUD

    class CRUDTestBase

      # The test description.
      #
      # @return [ String ] description The test description.
      attr_reader :description

      # The expected command monitoring events.
      attr_reader :expectations

      def setup_fail_point(client)
        if @fail_point_command
          client.use(:admin).command(@fail_point_command)
        end
      end

      def clear_fail_point(client)
        if @fail_point_command
          ClientRegistry.instance.global_client('root_authorized').use(:admin).command(BSON::Document.new(@fail_point_command).merge(mode: "off"))
        end
      end

      private

      def resolve_target(client, operation)
        if operation.database_options
          # Some CRUD spec tests specify "database options". In Ruby there is
          # no facility to specify options on a database, hence these are
          # lifted to the client.
          client = client.with(operation.database_options)
        end
        case operation.object
        when 'collection'
          client[@spec.collection_name].with(operation.collection_options)
        when 'database'
          client.database
        when 'client'
          client
        when 'gridfsbucket'
          client.database.fs
        else
          raise "Unknown target #{operation.object}"
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
mongo-2.21.0 spec/runners/crud/test_base.rb
mongo-2.20.1 spec/runners/crud/test_base.rb
mogno-2.20.0 spec/runners/crud/test_base.rb
mogno-1.0.0 spec/runners/crud/test_base.rb
mongo-2.20.0 spec/runners/crud/test_base.rb
mongo-2.19.3 spec/runners/crud/test_base.rb
mongo-2.19.2 spec/runners/crud/test_base.rb
mongo-2.19.1 spec/runners/crud/test_base.rb
mongo-2.19.0 spec/runners/crud/test_base.rb