@@ -13,16 +13,19 @@ class CloudSearchTest: XCTestCase {
13
13
14
14
override func setUp( ) {
15
15
super. setUp ( )
16
- let app = CloudApp . init ( appID: " xckzjbmtsbfb " , appKey: " 345f3324-c73c-4b15-94b5-9e89356c1b4e " )
16
+ let app = CloudApp . init ( appID: " zbzgfbmhvnzf " , appKey: " d9c4cdef-7586-4fa2-822b-cb815424d2c8 " )
17
17
app. setIsLogging ( true )
18
- app. setMasterKey ( " f5cc5cb3-ba0d-446d-9e51-e09be23c540d " )
18
+ app. setMasterKey ( " 2df6d3e7-a695-4ab0-b18a-d37a90af4dc9 " )
19
19
}
20
20
21
21
override func tearDown( ) {
22
22
// Put teardown code here. This method is called after the invocation of each test method in the class.
23
23
super. tearDown ( )
24
24
}
25
25
26
+ // DEPRECATED SINCE V0.2
27
+ /// SCROLL DOWN FOR THE NEW CloudQuery+Search tests
28
+
26
29
// should get data from server for near function
27
30
func testGetNear( ) {
28
31
let exp = expectationWithDescription ( " should get data from server for near function " )
@@ -595,5 +598,135 @@ class CloudSearchTest: XCTestCase {
595
598
waitForExpectationsWithTimeout ( 30 , handler: nil )
596
599
}
597
600
601
+
602
+
603
+ /// MARK
604
+ /// NEW un-deprecated tests
605
+
606
+ /// Saving data for tests
607
+ func testSaveData( ) {
608
+
609
+ }
610
+
611
+ // Basic search
612
+ func testBasicSearch( ) {
613
+ let exp = expectationWithDescription ( " basic search " )
614
+ let query = CloudQuery ( tableName: " Table " )
615
+ query. search ( " dog " )
616
+ query. find ( { resp in
617
+ if let results = resp. object as? [ CloudObject ] {
618
+ print ( results)
619
+ //returns CloudObjects of fields having string 'dog'
620
+ } else {
621
+ resp. log ( )
622
+ }
623
+ exp. fulfill ( )
624
+ } )
625
+ waitForExpectationsWithTimeout ( 30 , handler: nil )
626
+ }
627
+
628
+ // Phrases search
629
+ func testPhraseSearch( ) {
630
+ let exp = expectationWithDescription ( " phrases search " )
631
+ let query = CloudQuery ( tableName: " Table " )
632
+ query. search ( " three flowers honeybee " )
633
+ query. find ( { resp in
634
+ if let results = resp. object as? [ CloudObject ] {
635
+ print ( results)
636
+ // returns CloudObjects of fields having keywords either of tree OR flowers OR honeybees keywords
637
+ } else {
638
+ resp. log ( )
639
+ }
640
+ exp. fulfill ( )
641
+ } )
642
+ waitForExpectationsWithTimeout ( 30 , handler: nil )
643
+ }
644
+
645
+ // Exact phrases search
646
+ func testExactPhraseSearch( ) {
647
+ let exp = expectationWithDescription ( " exact phrase search " )
648
+ let query = CloudQuery ( tableName: " Table " )
649
+ query. search ( " \" three flowers \" " )
650
+ query. find ( { resp in
651
+ if let results = resp. object as? [ CloudObject ] {
652
+ print ( results)
653
+ // returns CloudObjects of fields having exact phrase "tree flowers"
654
+ } else {
655
+ resp. log ( )
656
+ }
657
+ exp. fulfill ( )
658
+ } )
659
+ waitForExpectationsWithTimeout ( 30 , handler: nil )
660
+ }
661
+
662
+ // Negation search
663
+ func testNegation( ) {
664
+ let exp = expectationWithDescription ( " negation search " )
665
+ let query = CloudQuery ( tableName: " Table " )
666
+ query. search ( " three flowers -honeybee " )
667
+ query. find ( { resp in
668
+ if let results = resp. object as? [ CloudObject ] {
669
+ print ( results)
670
+ // returns CloudObjects of fields having keyword "three" and "flowers" but not "honeybee"
671
+ } else {
672
+ resp. log ( )
673
+ }
674
+ exp. fulfill ( )
675
+ } )
676
+ waitForExpectationsWithTimeout ( 30 , handler: nil )
677
+ }
678
+
679
+ // Case sensitive search
680
+ func testCaseSensitive( ) {
681
+ let exp = expectationWithDescription ( " case sensitive search " )
682
+ let query = CloudQuery ( tableName: " Table " )
683
+ query. search ( " Dog " , caseSensitive: true )
684
+ query. find ( { resp in
685
+ if let results = resp. object as? [ CloudObject ] {
686
+ print ( results)
687
+ // returns appropriate result matching case sensitive words
688
+ } else {
689
+ resp. log ( )
690
+ }
691
+ exp. fulfill ( )
692
+ } )
693
+ waitForExpectationsWithTimeout ( 30 , handler: nil )
694
+ }
695
+
696
+ // Diacritic Sensitive
697
+ // è will not be equal to e
698
+ func testDiacriticSensitive( ) {
699
+ let exp = expectationWithDescription ( " diacritic sensitive search " )
700
+ let query = CloudQuery ( tableName: " Table " )
701
+ query. search ( " dôg " , diacriticSensitive: true )
702
+ query. find ( { resp in
703
+ if let results = resp. object as? [ CloudObject ] {
704
+ print ( results)
705
+ // returns []
706
+ } else {
707
+ resp. log ( )
708
+ }
709
+ exp. fulfill ( )
710
+ } )
711
+ waitForExpectationsWithTimeout ( 30 , handler: nil )
712
+ }
713
+
714
+ // language
715
+ func testLanguage( ) {
716
+ let exp = expectationWithDescription ( " language specific search " )
717
+ let query = CloudQuery ( tableName: " Table " )
718
+ query. search ( " algunas " , language: " es " )
719
+ query. find ( { resp in
720
+ if let results = resp. object as? [ CloudObject ] {
721
+ print ( results)
722
+ // returns []
723
+ } else {
724
+ resp. log ( )
725
+ }
726
+ exp. fulfill ( )
727
+ } )
728
+ waitForExpectationsWithTimeout ( 30 , handler: nil )
729
+ }
730
+
598
731
599
732
}
0 commit comments