Sha256: e5974c95d661e52401b00ba034c2d8e8cda65cc49577780b508b8924adab3f8d

Contents?: true

Size: 1.1 KB

Versions: 28

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

describe Mongo::Operation::DropIndex do
  before do
    authorized_collection.indexes.drop_all
  end

  describe '#execute' do

    context 'when the index exists' do

      let(:spec) do
        { another: -1 }
      end

      before do
        authorized_collection.indexes.create_one(spec, unique: true)
      end

      let(:operation) do
        described_class.new(
          db_name: SpecConfig.instance.test_db,
          coll_name: TEST_COLL,
          index_name: 'another_-1'
        )
      end

      let(:response) do
        operation.execute(authorized_primary)
      end

      it 'removes the index' do
        expect(response).to be_successful
      end
    end

    context 'when the index does not exist' do

      let(:operation) do
        described_class.new(
          db_name: SpecConfig.instance.test_db,
          coll_name: TEST_COLL,
          index_name: 'another_blah'
        )
      end

      it 'raises an exception' do
        expect {
          operation.execute(authorized_primary)
        }.to raise_error(Mongo::Error::OperationFailure)
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongo-2.8.0/spec/mongo/operation/drop_index_spec.rb
mongo-2.11.6 spec/mongo/operation/drop_index_spec.rb
mongo-2.10.5 spec/mongo/operation/drop_index_spec.rb
mongo-2.11.5 spec/mongo/operation/drop_index_spec.rb
mongo-2.11.4 spec/mongo/operation/drop_index_spec.rb
mongo-2.10.4 spec/mongo/operation/drop_index_spec.rb
mongo-2.11.3 spec/mongo/operation/drop_index_spec.rb
mongo-2.11.2 spec/mongo/operation/drop_index_spec.rb
mongo-2.11.1 spec/mongo/operation/drop_index_spec.rb
mongo-2.10.3 spec/mongo/operation/drop_index_spec.rb
mongo-2.11.0 spec/mongo/operation/drop_index_spec.rb
mongo-2.9.2 spec/mongo/operation/drop_index_spec.rb
mongo-2.10.2 spec/mongo/operation/drop_index_spec.rb
mongo-2.11.0.rc0 spec/mongo/operation/drop_index_spec.rb
mongo-2.10.1 spec/mongo/operation/drop_index_spec.rb
mongo-2.10.0 spec/mongo/operation/drop_index_spec.rb
mongo-2.9.1 spec/mongo/operation/drop_index_spec.rb
mongo-2.10.0.rc0 spec/mongo/operation/drop_index_spec.rb
mongo-2.9.1.rc0 spec/mongo/operation/drop_index_spec.rb
mongo-2.9.0 spec/mongo/operation/drop_index_spec.rb