Skip to content

Commit 4e75198

Browse files
authored
Fix primary key tests (#147)
1 parent e1b3b3b commit 4e75198

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

spec/meilisearch/index/documents_spec.rb

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@
276276
end
277277
end
278278

279-
context 'Wrong primary-key (attribute does not exist) added when pushing documents' do
279+
context 'Wrong primary-key (attribute does not exist) when pushing documents' do
280280
before(:all) do
281281
@uid = SecureRandom.hex(4)
282282
@client.create_index(@uid)
@@ -289,36 +289,17 @@
289289
{ unique: 3, id: 1, title: 'Le Rouge et le Noir' }
290290
end
291291

292-
it 'adds the primary-key but not the documents' do
292+
it 'does not add the primary key and the documents either' do
293293
response = index.update_documents(documents, 'objectId')
294294
expect(response).to be_a(Hash)
295295
expect(response).to have_key('updateId')
296296
sleep(0.2)
297-
expect(index.fetch_primary_key).to eq('objectId')
298-
expect(index.get_update_status(response['updateId'])['status']).to eq('failed')
299-
end
300-
301-
it 'succeeds to add document with the primary-key' do
302-
response = index.add_documents({ objectId: 1, title: 'Le Rouge et le Noir' }, 'id')
303-
expect(response).to be_a(Hash)
304-
expect(response).to have_key('updateId')
305-
sleep(0.2)
306-
expect(index.fetch_primary_key).to eq('objectId')
307-
expect(index.get_update_status(response['updateId'])['status']).to eq('processed')
308-
expect(index.documents.count).to eq(1)
309-
end
310-
311-
it 'does not take into account the new primary key' do
312-
response = index.add_documents({ id: 2, title: 'Le Petit Prince' }, 'id')
313-
expect(response).to be_a(Hash)
314-
expect(response).to have_key('updateId')
315-
sleep(0.2)
316-
expect(index.fetch_primary_key).to eq('objectId')
297+
expect(index.fetch_primary_key).to be_nil
317298
expect(index.get_update_status(response['updateId'])['status']).to eq('failed')
318299
end
319300
end
320301

321-
context 'Wrong primary-key (attribute bad formatted) added when pushing documents' do
302+
context 'Wrong primary-key (attribute bad formatted) when pushing documents' do
322303
before(:all) do
323304
@uid = SecureRandom.hex(4)
324305
@client.create_index(@uid)
@@ -331,12 +312,12 @@
331312
{ id: 1, title: 'Le Rouge et le Noir' }
332313
end
333314

334-
it 'adds the primary-key but not the documents' do
315+
it 'does not add the primary key and the documents either' do
335316
response = index.add_documents(documents, 'title')
336317
expect(response).to be_a(Hash)
337318
expect(response).to have_key('updateId')
338319
sleep(0.2)
339-
expect(index.fetch_primary_key).to eq('title')
320+
expect(index.fetch_primary_key).to be_nil
340321
expect(index.get_update_status(response['updateId'])['status']).to eq('failed')
341322
expect(index.documents.count).to eq(0)
342323
end

0 commit comments

Comments
 (0)