|
45 | 45 | end |
46 | 46 |
|
47 | 47 | it 'updates primary-key of index if not defined before' do |
| 48 | + index = client.create_index('uid', primaryKey: 'primary_key') |
| 49 | + index.update(primaryKey: 'new_primary_key') |
| 50 | + expect(index).to be_a(MeiliSearch::Index) |
| 51 | + expect(index.uid).to eq('uid') |
| 52 | + expect(index.primary_key).to eq('new_primary_key') |
| 53 | + expect(index.fetch_primary_key).to eq('new_primary_key') |
| 54 | + expect(index.created_at).to be_a(Time) |
| 55 | + expect(index.created_at).to be_within(60).of(Time.now) |
| 56 | + expect(index.updated_at).to be_a(Time) |
| 57 | + expect(index.updated_at).to be_within(60).of(Time.now) |
| 58 | + end |
| 59 | + |
| 60 | + it 'updates primary-key of index if has been defined before but there is not docs' do |
48 | 61 | index = client.create_index('uid') |
49 | 62 | index.update(primaryKey: 'new_primary_key') |
50 | 63 | expect(index).to be_a(MeiliSearch::Index) |
|
58 | 71 | end |
59 | 72 |
|
60 | 73 | it 'returns error if trying to update primary-key if it is already defined' do |
61 | | - index = client.create_index('uid', primaryKey: 'primary_key') |
| 74 | + index = client.index('uid') |
| 75 | + update = index.add_documents({ id: 1, title: 'My Title' }) |
| 76 | + index.wait_for_pending_update(update['updateId']) |
62 | 77 | expect do |
63 | 78 | index.update(primaryKey: 'new_primary_key') |
64 | 79 | end.to raise_meilisearch_api_error_with( |
65 | 80 | 400, |
66 | | - 'primary_key_already_present', |
67 | | - 'invalid_request_error' |
| 81 | + 'index_primary_key_already_exists', |
| 82 | + 'invalid_request' |
68 | 83 | ) |
69 | 84 | end |
70 | 85 |
|
|
0 commit comments