Sha256: 4d8580795e0e446cdcc980b6069c78095fa7847a7bbb3251434cbcc3c0b21456
Contents?: true
Size: 1.33 KB
Versions: 6
Compression:
Stored size: 1.33 KB
Contents
require 'spec_helper' describe Mongo::Operation::CreateIndex do describe '#execute' do context 'when the index is created' do let(:spec) do { key: { random: 1 }, name: 'random_1', unique: true } end let(:operation) do described_class.new(indexes: [ spec ], db_name: TEST_DB, coll_name: TEST_COLL) end let(:response) do operation.execute(authorized_primary) end after do authorized_collection.indexes.drop_one('random_1') end it 'returns ok' do expect(response).to be_successful end end context 'when index creation fails' do let(:spec) do { key: { random: 1 }, name: 'random_1', unique: true } end let(:operation) do described_class.new(indexes: [ spec ], db_name: TEST_DB, coll_name: TEST_COLL) end let(:second_operation) do described_class.new(indexes: [ spec.merge(unique: false) ], db_name: TEST_DB, coll_name: TEST_COLL) end before do operation.execute(authorized_primary) end after do authorized_collection.indexes.drop_one('random_1') end it 'raises an exception' do expect { second_operation.execute(authorized_primary) }.to raise_error(Mongo::Error::OperationFailure) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems