Add test for search after API

This commit is contained in:
Shulhi Sapli 2018-07-31 15:36:50 +08:00
parent 4967c62843
commit 13df8a8674
3 changed files with 20 additions and 2 deletions

View File

@ -55,6 +55,7 @@ instance (Arbitrary a, Typeable a) => Arbitrary (Hit a) where
<*> arbitrary
<*> arbitraryScore
<*> arbitrary
<*> return Nothing
<*> arbitrary
<*> arbitrary
@ -183,7 +184,7 @@ instance Arbitrary Query where
instance Arbitrary Filter where
arbitrary =
Filter <$> arbitrary
Filter <$> arbitrary
shrink (Filter q) =
Filter <$> shrink q

View File

@ -14,7 +14,7 @@ spec =
let sortSpec = DefaultSortSpec $ mkSort (FieldName "age") Ascending
let search = Search Nothing
Nothing (Just [sortSpec]) Nothing Nothing
False (From 0) (Size 10) SearchTypeQueryThenFetch Nothing Nothing
False (From 0) (Size 10) SearchTypeQueryThenFetch Nothing Nothing Nothing
Nothing Nothing
result <- searchTweets search
let myTweet = grabFirst result

View File

@ -18,6 +18,7 @@ import Test.Import
import Prelude
import qualified Data.Aeson as Aeson
import qualified Test.Aggregation as Aggregation
import qualified Test.BulkAPI as Bulk
import qualified Test.Documents as Documents
@ -117,3 +118,19 @@ main = hspec $ do
regular_search `shouldBe` Right exampleTweet -- Check that the size restrtiction is being honored
liftIO $
scan_search `shouldMatchList` [Just exampleTweet, Just otherTweet]
describe "Search After API" $
it "returns document for search after query" $ withTestEnv $ do
_ <- insertData
_ <- insertOther
let
sortSpec = DefaultSortSpec $ mkSort (FieldName "user") Ascending
searchAfterKey = [Aeson.toJSON ("bitemyapp" :: String)]
search = Search Nothing
Nothing (Just [sortSpec]) Nothing Nothing
False (From 0) (Size 10) SearchTypeQueryThenFetch (Just searchAfterKey)
Nothing Nothing Nothing Nothing
result <- searchTweets search
let myTweet = grabFirst result
liftIO $
myTweet `shouldBe` Right otherTweet