File tree Expand file tree Collapse file tree 4 files changed +12
-11
lines changed
Tests/MeiliSearchUnitTests Expand file tree Collapse file tree 4 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ public struct MeiliSearch {
156156 UID: String ,
157157 documents: [ T ] ,
158158 encoder: JSONEncoder ? = nil ,
159- primaryKey: String ? ,
159+ primaryKey: String ? = nil ,
160160 _ completion: @escaping ( Result < Update , Swift . Error > ) -> Void ) where T: Encodable {
161161 self . documents. add (
162162 UID,
@@ -184,7 +184,7 @@ public struct MeiliSearch {
184184 public func addDocuments(
185185 UID: String ,
186186 documents: Data ,
187- primaryKey: String ? ,
187+ primaryKey: String ? = nil ,
188188 _ completion: @escaping ( Result < Update , Swift . Error > ) -> Void ) {
189189 self . documents. add (
190190 UID,
@@ -212,7 +212,7 @@ public struct MeiliSearch {
212212 public func updateDocuments(
213213 UID: String ,
214214 documents: Data ,
215- primaryKey: String ? ,
215+ primaryKey: String ? = nil ,
216216 _ completion: @escaping ( Result < Update , Swift . Error > ) -> Void ) {
217217 self . documents. update (
218218 UID,
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ struct Documents {
7070 func add(
7171 _ UID: String ,
7272 _ document: Data ,
73- _ primaryKey: String ? ,
73+ _ primaryKey: String ? = nil ,
7474 _ completion: @escaping ( Result < Update , Swift . Error > ) -> Void ) {
7575
7676 var query : String = " /indexes/ \( UID) /documents "
@@ -93,7 +93,7 @@ struct Documents {
9393 _ UID: String ,
9494 _ documents: [ T ] ,
9595 _ encoder: JSONEncoder ? = nil ,
96- _ primaryKey: String ? ,
96+ _ primaryKey: String ? = nil ,
9797 _ completion: @escaping ( Result < Update , Swift . Error > ) -> Void ) where T: Encodable {
9898
9999 var query : String = " /indexes/ \( UID) /documents "
@@ -127,7 +127,7 @@ struct Documents {
127127 func update(
128128 _ UID: String ,
129129 _ document: Data ,
130- _ primaryKey: String ? ,
130+ _ primaryKey: String ? = nil ,
131131 _ completion: @escaping ( Result < Update , Swift . Error > ) -> Void ) {
132132
133133 var query : String = " /indexes/ \( UID) /documents "
Original file line number Diff line number Diff line change @@ -89,7 +89,10 @@ public extension MeiliSearch {
8989 case . invalidJSON:
9090 return " Invalid json "
9191 case . invalidURL( let url) :
92- return " Invalid URL: \( url) "
92+ if let strUrl: String = url {
93+ return " Invalid URL: \( strUrl) "
94+ }
95+ return " Invalid URL "
9396 case . meiliSearchCommunicationError( let message, let url) :
9497 return " meiliSearchCommunicationError \( message) \( url) "
9598
Original file line number Diff line number Diff line change @@ -61,8 +61,8 @@ class DocumentsTests: XCTestCase {
6161
6262 self . client. addDocuments (
6363 UID: uid,
64- documents: [ movie] ,
65- primaryKey : " " ) { result in
64+ documents: [ movie]
65+ ) { result in
6666
6767 switch result {
6868 case . success( let update) :
@@ -71,7 +71,6 @@ class DocumentsTests: XCTestCase {
7171 case . failure:
7272 XCTFail ( " Failed to add or replace Movies document " )
7373 }
74-
7574 }
7675
7776 self . wait ( for: [ expectation] , timeout: 1.0 )
@@ -255,7 +254,6 @@ class DocumentsTests: XCTestCase {
255254 // Start the test with the mocked server
256255
257256 let uid : String = " Movies "
258- let limit : Int = 10
259257
260258 let expectation = XCTestExpectation ( description: " Get Movies documents " )
261259
You can’t perform that action at this time.
0 commit comments