git.iko.soy/typeable/bloodhound
on master help sign in
Add test for search after API
13df8a8Shulhi Sapli
tests/V5/Test/Generators.hs+2−1
@@ -55,6 +55,7 @@ instance (Arbitrary a, Typeable a) => Arbitrary (Hit a) where
55 <*> arbitrary
55 <*> arbitrary
56 <*> arbitraryScore
56 <*> arbitraryScore
57 <*> arbitrary
57 <*> arbitrary
58+ <*> return Nothing
58 <*> arbitrary
59 <*> arbitrary
59 <*> arbitrary
60 <*> arbitrary
60
61
@@ -183,7 +184,7 @@ instance Arbitrary Query where
183
184
184instance Arbitrary Filter where
185instance Arbitrary Filter where
185 arbitrary =
186 arbitrary =
186− Filter <$> arbitrary
187+ Filter <$> arbitrary
187 shrink (Filter q) =
188 shrink (Filter q) =
188 Filter <$> shrink q
189 Filter <$> shrink q
189
190
tests/V5/Test/Sorting.hs+1−1
@@ -14,7 +14,7 @@ spec =
14 let sortSpec = DefaultSortSpec $ mkSort (FieldName "age") Ascending
14 let sortSpec = DefaultSortSpec $ mkSort (FieldName "age") Ascending
15 let search = Search Nothing
15 let search = Search Nothing
16 Nothing (Just [sortSpec]) Nothing Nothing
16 Nothing (Just [sortSpec]) Nothing Nothing
17− False (From 0) (Size 10) SearchTypeQueryThenFetch Nothing Nothing
17+ False (From 0) (Size 10) SearchTypeQueryThenFetch Nothing Nothing Nothing
18 Nothing Nothing
18 Nothing Nothing
19 result <- searchTweets search
19 result <- searchTweets search
20 let myTweet = grabFirst result
20 let myTweet = grabFirst result
tests/V5/tests.hs+17
@@ -18,6 +18,7 @@ import Test.Import
18
18
19import Prelude
19import Prelude
20
20
21+import qualified Data.Aeson as Aeson
21import qualified Test.Aggregation as Aggregation
22import qualified Test.Aggregation as Aggregation
22import qualified Test.BulkAPI as Bulk
23import qualified Test.BulkAPI as Bulk
23import qualified Test.Documents as Documents
24import qualified Test.Documents as Documents
@@ -117,3 +118,19 @@ main = hspec $ do
117 regular_search `shouldBe` Right exampleTweet -- Check that the size restrtiction is being honored
118 regular_search `shouldBe` Right exampleTweet -- Check that the size restrtiction is being honored
118 liftIO $
119 liftIO $
119 scan_search `shouldMatchList` [Just exampleTweet, Just otherTweet]
120 scan_search `shouldMatchList` [Just exampleTweet, Just otherTweet]
121+
122+ describe "Search After API" $
123+ it "returns document for search after query" $ withTestEnv $ do
124+ _ <- insertData
125+ _ <- insertOther
126+ let
127+ sortSpec = DefaultSortSpec $ mkSort (FieldName "user") Ascending
128+ searchAfterKey = [Aeson.toJSON ("bitemyapp" :: String)]
129+ search = Search Nothing
130+ Nothing (Just [sortSpec]) Nothing Nothing
131+ False (From 0) (Size 10) SearchTypeQueryThenFetch (Just searchAfterKey)
132+ Nothing Nothing Nothing Nothing
133+ result <- searchTweets search
134+ let myTweet = grabFirst result
135+ liftIO $
136+ myTweet `shouldBe` Right otherTweet