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
|
require 'spec_helper'
describe Mongo::Operation::Write::Command::DropIndex do
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: 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: 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
|