Skip to content

Commit 21e903e

Browse files
committed
Make the add JSON/NDJSO/CSV documents tests to use a custom id
- To add a bit more significance to the tests - Because meilisearch automatically infers the primary key if it contains "id" in it -- https://docs.meilisearch.com/learn/core_concepts/documents.html#meilisearch-guesses-your-primary-key
1 parent 9d94183 commit 21e903e

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

spec/meilisearch/index/documents_spec.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@
3939
it 'adds JSON documents (as a array of documents)' do
4040
documents = <<JSON
4141
[
42-
{ "objectId": 123, "title": "Pride and Prejudice", "comment": "A great book" },
43-
{ "objectId": 456, "title": "Le Petit Prince", "comment": "A french book" },
44-
{ "objectId": 1, "title": "Alice In Wonderland", "comment": "A weird book" },
45-
{ "objectId": 1344, "title": "The Hobbit", "comment": "An awesome book" },
46-
{ "objectId": 4, "title": "Harry Potter and the Half-Blood Prince", "comment": "The best book" }
42+
{ "objectRef": 123, "title": "Pride and Prejudice", "comment": "A great book" },
43+
{ "objectRef": 456, "title": "Le Petit Prince", "comment": "A french book" },
44+
{ "objectRef": 1, "title": "Alice In Wonderland", "comment": "A weird book" },
45+
{ "objectRef": 1344, "title": "The Hobbit", "comment": "An awesome book" },
46+
{ "objectRef": 4, "title": "Harry Potter and the Half-Blood Prince", "comment": "The best book" }
4747
]
4848
JSON
49-
response = index.add_documents_json(documents)
49+
response = index.add_documents_json(documents, 'objectRef')
5050

5151
expect(response).to be_a(Hash)
5252
expect(response).to have_key('updateId')
@@ -56,12 +56,12 @@
5656

5757
it 'adds NDJSON documents (as a array of documents)' do
5858
documents = <<NDJSON
59-
{ "objectId": 123, "title": "Pride and Prejudice", "comment": "A great book" }
60-
{ "objectId": 456, "title": "Le Petit Prince", "comment": "A french book" }
61-
{ "objectId": 1, "title": "Alice In Wonderland", "comment": "A weird book" }
62-
{ "objectId": 4, "title": "Harry Potter and the Half-Blood Prince", "comment": "The best book" }
59+
{ "objectRef": 123, "title": "Pride and Prejudice", "comment": "A great book" }
60+
{ "objectRef": 456, "title": "Le Petit Prince", "comment": "A french book" }
61+
{ "objectRef": 1, "title": "Alice In Wonderland", "comment": "A weird book" }
62+
{ "objectRef": 4, "title": "Harry Potter and the Half-Blood Prince", "comment": "The best book" }
6363
NDJSON
64-
response = index.add_documents_ndjson(documents)
64+
response = index.add_documents_ndjson(documents, 'objectRef')
6565
expect(response).to be_a(Hash)
6666
expect(response).to have_key('updateId')
6767
index.wait_for_pending_update(response['updateId'])
@@ -70,12 +70,12 @@
7070

7171
it 'adds CSV documents (as a array of documents)' do
7272
documents = <<CSV
73-
"objectId:number","title:string","comment:string"
73+
"objectRef:number","title:string","comment:string"
7474
"1239","Pride and Prejudice","A great book"
7575
"4569","Le Petit Prince","A french book"
7676
"49","Harry Potter and the Half-Blood Prince","The best book"
7777
CSV
78-
response = index.add_documents_csv(documents)
78+
response = index.add_documents_csv(documents, 'objectRef')
7979
expect(response).to be_a(Hash)
8080
expect(response).to have_key('updateId')
8181
index.wait_for_pending_update(response['updateId'])

0 commit comments

Comments
 (0)