git.iko.soy/typeable/bloodhound
on master help sign in
Add test for search after API
commit13df8a8674cc3b8bd7d4d73362826b3db8344679 authorShulhi Sapli <shulhi@gmail.com> dateTue 31 Jul 2018, 15:36 (8 years ago) parent4967c62
3 files changed+20−2
tests/V5/Test/Generators.hs+2−1 tests/V5/Test/Sorting.hs+1−1 tests/V5/tests.hs+17
tests/V5/Test/Generators.hs+2−1
@@ -55,6 +55,7 @@ instance (Arbitrary a, Typeable a) => Arbitrary (Hit a) where
5555 <*> arbitrary
5656 <*> arbitraryScore
5757 <*> arbitrary
58+ <*> return Nothing
5859 <*> arbitrary
5960 <*> arbitrary
6061
@@ -183,7 +184,7 @@ instance Arbitrary Query where
183184
184185instance Arbitrary Filter where
185186 arbitrary =
186− Filter <$> arbitrary
187+ Filter <$> arbitrary
187188 shrink (Filter q) =
188189 Filter <$> shrink q
189190
tests/V5/Test/Sorting.hs+1−1
@@ -14,7 +14,7 @@ spec =
1414 let sortSpec = DefaultSortSpec $ mkSort (FieldName "age") Ascending
1515 let search = Search Nothing
1616 Nothing (Just [sortSpec]) Nothing Nothing
17− False (From 0) (Size 10) SearchTypeQueryThenFetch Nothing Nothing
17+ False (From 0) (Size 10) SearchTypeQueryThenFetch Nothing Nothing Nothing
1818 Nothing Nothing
1919 result <- searchTweets search
2020 let myTweet = grabFirst result
tests/V5/tests.hs+17
@@ -18,6 +18,7 @@ import Test.Import
1818
1919import Prelude
2020
21+import qualified Data.Aeson as Aeson
2122import qualified Test.Aggregation as Aggregation
2223import qualified Test.BulkAPI as Bulk
2324import qualified Test.Documents as Documents
@@ -117,3 +118,19 @@ main = hspec $ do
117118 regular_search `shouldBe` Right exampleTweet -- Check that the size restrtiction is being honored
118119 liftIO $
119120 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