@@ -259,7 +259,6 @@ class IndexTests: XCTestCase {
259259 } )
260260 }
261261 } )
262-
263262 waitForExpectationsWithTimeout ( expectationTimeout, handler: nil )
264263 }
265264
@@ -331,6 +330,44 @@ class IndexTests: XCTestCase {
331330 waitForExpectationsWithTimeout ( expectationTimeout, handler: nil )
332331 }
333332
333+ func testGetObjectsFiltered( ) {
334+ let expectation = expectationWithDescription ( #function)
335+ let objects : [ [ String : AnyObject ] ] = [
336+ [ " objectID " : " 1 " , " name " : " Snoopy " , " kind " : " dog " ] ,
337+ [ " objectID " : " 2 " , " name " : " Woodstock " , " kind " : " bird " ]
338+ ]
339+ index. addObjects ( objects, completionHandler: { ( content, error) -> Void in
340+ guard let content = content else {
341+ XCTFail ( " Error during addObjetcs: \( error) " )
342+ expectation. fulfill ( )
343+ return
344+ }
345+ self . index. waitTask ( content [ " taskID " ] as! Int , completionHandler: { ( content, error) -> Void in
346+ guard error == nil else {
347+ XCTFail ( " Error during waitTask: \( error) " )
348+ expectation. fulfill ( )
349+ return
350+ }
351+ self . index. getObjects ( [ " 1 " , " 2 " ] , attributesToRetrieve: [ " name " , " nonexistent " ] , completionHandler: { ( content, error) -> Void in
352+ guard let content = content else {
353+ XCTFail ( " Error during getObjects: \( error) " )
354+ expectation. fulfill ( )
355+ return
356+ }
357+ let items = content [ " results " ] as! [ [ String : String ] ]
358+ XCTAssertEqual ( 2 , items. count)
359+ XCTAssertEqual ( items [ 0 ] [ " name " ] ! as String , " Snoopy " )
360+ XCTAssertEqual ( items [ 1 ] [ " name " ] ! as String , " Woodstock " )
361+ XCTAssertNil ( items [ 0 ] [ " kind " ] )
362+ XCTAssertNil ( items [ 1 ] [ " kind " ] )
363+ expectation. fulfill ( )
364+ } )
365+ } )
366+ } )
367+
368+ waitForExpectationsWithTimeout ( expectationTimeout, handler: nil )
369+ }
370+
334371 func testPartialUpdateObject( ) {
335372 let expectation = expectationWithDescription ( " testPartialUpdateObject " )
336373 let object = [ " city " : " New York " , " initial " : " NY " , " objectID " : " a/go/?à " ]
0 commit comments