Sha256: f7c6a12acd8a3ea1539334eda4f1620703837cc914bb0379850cda599cef0c8b

Contents?: true

Size: 1.35 KB

Versions: 18

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

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
          client.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

18 entries across 18 versions & 1 rubygems

Version Path
mongo-2.16.4 spec/runners/crud/test_base.rb
mongo-2.17.4 spec/runners/crud/test_base.rb
mongo-2.18.3 spec/runners/crud/test_base.rb
mongo-2.18.2 spec/runners/crud/test_base.rb
mongo-2.17.3 spec/runners/crud/test_base.rb
mongo-2.18.1 spec/runners/crud/test_base.rb
mongo-2.18.0 spec/runners/crud/test_base.rb
mongo-2.17.2 spec/runners/crud/test_base.rb
mongo-2.16.3 spec/runners/crud/test_base.rb
mongo-2.18.0.beta1 spec/runners/crud/test_base.rb
mongo-2.16.2 spec/runners/crud/test_base.rb
mongo-2.17.1 spec/runners/crud/test_base.rb
mongo-2.16.1 spec/runners/crud/test_base.rb
mongo-2.17.0 spec/runners/crud/test_base.rb
mongo-2.16.0 spec/runners/crud/test_base.rb
mongo-2.15.1 spec/runners/crud/test_base.rb
mongo-2.16.0.alpha1 spec/runners/crud/test_base.rb
mongo-2.15.0 spec/runners/crud/test_base.rb