mirror of
https://github.com/typeable/bloodhound.git
synced 2024-08-16 03:40:30 +03:00
Add test for search after API
This commit is contained in:
parent
4967c62843
commit
13df8a8674
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user