@@ -15,7 +15,7 @@
15module Main where
15module Main where
17import Control.Applicative
17import Control.Applicative
18−import Control.Error
18+import Control.Error hiding (Script)
19import Control.Exception (evaluate)
19import Control.Exception (evaluate)
20import Control.Monad
20import Control.Monad
21import Control.Monad.Catch
21import Control.Monad.Catch
@@ -509,6 +509,11 @@ instance ApproxEq TemplateName
509instance ApproxEq TemplatePattern
509instance ApproxEq TemplatePattern
510instance ApproxEq QueryString
510instance ApproxEq QueryString
511instance ApproxEq FieldName
511instance ApproxEq FieldName
512+instance ApproxEq Script
513+instance ApproxEq ScriptLanguage
514+instance ApproxEq ScriptInline
515+instance ApproxEq ScriptId
516+instance ApproxEq ScriptParams where (=~) = (==)
512instance ApproxEq CacheName
517instance ApproxEq CacheName
513instance ApproxEq CacheKey
518instance ApproxEq CacheKey
514instance ApproxEq Existence
519instance ApproxEq Existence
@@ -563,11 +568,8 @@ instance ApproxEq FunctionScoreQuery
563instance ApproxEq BoostMode
568instance ApproxEq BoostMode
564instance ApproxEq ScoreMode
569instance ApproxEq ScoreMode
565instance ApproxEq FunctionScoreFunctions
570instance ApproxEq FunctionScoreFunctions
566−instance ApproxEq ComponentFunctionScoreFunction
567instance ApproxEq FunctionScoreFunction
571instance ApproxEq FunctionScoreFunction
568−instance ApproxEq FunctionScoreScript
572+instance ApproxEq ComponentFunctionScoreFunction
569−instance ApproxEq FunctionScoreScriptInline
570−instance ApproxEq FunctionScoreScriptParams where (=~) = (==)
571instance ApproxEq Weight where (=~) = (==)
573instance ApproxEq Weight where (=~) = (==)
572instance ApproxEq Seed where (=~) = (==)
574instance ApproxEq Seed where (=~) = (==)
573instance ApproxEq FieldValueFactor
575instance ApproxEq FieldValueFactor
@@ -686,8 +688,12 @@ instance (Arbitrary a, Typeable a) => Arbitrary (Hit a) where
686 <*> arbitraryScore
688 <*> arbitraryScore
687 <*> arbitrary
689 <*> arbitrary
688 <*> arbitrary
690 <*> arbitrary
689 shrink = genericShrink
692 shrink = genericShrink
694+instance Arbitrary HitFields where
695+ arbitrary = pure (HitFields M.empty)
692instance (Arbitrary a, Typeable a) => Arbitrary (SearchHits a) where
698instance (Arbitrary a, Typeable a) => Arbitrary (SearchHits a) where
693 arbitrary = reduceSize $ do
699 arbitrary = reduceSize $ do
@@ -740,6 +746,27 @@ instance Arbitrary FieldName where
740 arbitrary = FieldName . T.pack <$> listOf1 arbitraryAlphaNum
746 arbitrary = FieldName . T.pack <$> listOf1 arbitraryAlphaNum
741 shrink = genericShrink
747 shrink = genericShrink
749+instance Arbitrary ScriptFields where
751+ pure $ ScriptFields $
756+instance Arbitrary Script where arbitrary = sopArbitrary; shrink = genericShrink
757+instance Arbitrary ScriptLanguage where arbitrary = sopArbitrary; shrink = genericShrink
758+instance Arbitrary ScriptInline where arbitrary = sopArbitrary; shrink = genericShrink
759+instance Arbitrary ScriptId where arbitrary = sopArbitrary; shrink = genericShrink
761+instance Arbitrary ScriptParams where
763+ pure $ ScriptParams $
764+ HM.fromList [ ("a", Number 42)
765+ , ("b", String "forty two")
744instance Arbitrary RegexpFlags where
771instance Arbitrary RegexpFlags where
745 arbitrary = oneof [ pure AllRegexpFlags
772 arbitrary = oneof [ pure AllRegexpFlags
@@ -885,18 +912,8 @@ instance Arbitrary FunctionScoreQuery where arbitrary = sopArbitrary; shrink = g
885instance Arbitrary BoostMode where arbitrary = sopArbitrary; shrink = genericShrink
912instance Arbitrary BoostMode where arbitrary = sopArbitrary; shrink = genericShrink
886instance Arbitrary ScoreMode where arbitrary = sopArbitrary; shrink = genericShrink
913instance Arbitrary ScoreMode where arbitrary = sopArbitrary; shrink = genericShrink
887instance Arbitrary FunctionScoreFunctions where arbitrary = sopArbitrary; shrink = genericShrink
914instance Arbitrary FunctionScoreFunctions where arbitrary = sopArbitrary; shrink = genericShrink
888−instance Arbitrary ComponentFunctionScoreFunction where arbitrary = sopArbitrary; shrink = genericShrink
889instance Arbitrary FunctionScoreFunction where arbitrary = sopArbitrary; shrink = genericShrink
915instance Arbitrary FunctionScoreFunction where arbitrary = sopArbitrary; shrink = genericShrink
890−instance Arbitrary FunctionScoreScript where arbitrary = sopArbitrary; shrink = genericShrink
891−instance Arbitrary FunctionScoreScriptInline where arbitrary = sopArbitrary; shrink = genericShrink
916+instance Arbitrary ComponentFunctionScoreFunction where arbitrary = sopArbitrary; shrink = genericShrink
892−instance Arbitrary FunctionScoreScriptParams where
894− pure $ FunctionScoreScriptParams $
895− HM.fromList [ ("a", Number 42)
896− , ("b", String "forty two")
900instance Arbitrary Weight where arbitrary = sopArbitrary; shrink = genericShrink
917instance Arbitrary Weight where arbitrary = sopArbitrary; shrink = genericShrink
901instance Arbitrary Seed where arbitrary = sopArbitrary; shrink = genericShrink
918instance Arbitrary Seed where arbitrary = sopArbitrary; shrink = genericShrink
902instance Arbitrary FieldValueFactor where arbitrary = sopArbitrary; shrink = genericShrink
919instance Arbitrary FieldValueFactor where arbitrary = sopArbitrary; shrink = genericShrink
@@ -1192,7 +1209,7 @@ main = hspec $ do
1192 let search = Search Nothing
1209 let search = Search Nothing
1193 Nothing (Just [sortSpec]) Nothing Nothing
1210 Nothing (Just [sortSpec]) Nothing Nothing
1194 False (From 0) (Size 10) SearchTypeQueryThenFetch Nothing Nothing
1211 False (From 0) (Size 10) SearchTypeQueryThenFetch Nothing Nothing
1195− Nothing
1212+ Nothing Nothing
1196 result <- searchTweets search
1213 result <- searchTweets search
1197 let myTweet = grabFirst result
1214 let myTweet = grabFirst result
1198 liftIO $
1215 liftIO $
@@ -1659,6 +1676,11 @@ main = hspec $ do
1659 propJSON (Proxy :: Proxy TemplatePattern)
1676 propJSON (Proxy :: Proxy TemplatePattern)
1660 propJSON (Proxy :: Proxy QueryString)
1677 propJSON (Proxy :: Proxy QueryString)
1661 propJSON (Proxy :: Proxy FieldName)
1678 propJSON (Proxy :: Proxy FieldName)
1679+ propJSON (Proxy :: Proxy Script)
1680+ propJSON (Proxy :: Proxy ScriptLanguage)
1681+ propJSON (Proxy :: Proxy ScriptInline)
1682+ propJSON (Proxy :: Proxy ScriptId)
1683+ propJSON (Proxy :: Proxy ScriptParams)
1662 propJSON (Proxy :: Proxy CacheName)
1684 propJSON (Proxy :: Proxy CacheName)
1663 propJSON (Proxy :: Proxy CacheKey)
1685 propJSON (Proxy :: Proxy CacheKey)
1664 propJSON (Proxy :: Proxy Existence)
1686 propJSON (Proxy :: Proxy Existence)
@@ -1713,7 +1735,6 @@ main = hspec $ do
1713 propJSON (Proxy :: Proxy BoostMode)
1735 propJSON (Proxy :: Proxy BoostMode)
1714 propJSON (Proxy :: Proxy ScoreMode)
1736 propJSON (Proxy :: Proxy ScoreMode)
1715 propJSON (Proxy :: Proxy ComponentFunctionScoreFunction)
1737 propJSON (Proxy :: Proxy ComponentFunctionScoreFunction)
1716− propJSON (Proxy :: Proxy FunctionScoreScript)
1717 propJSON (Proxy :: Proxy FieldValueFactor)
1738 propJSON (Proxy :: Proxy FieldValueFactor)
1718 propJSON (Proxy :: Proxy FactorModifier)
1739 propJSON (Proxy :: Proxy FactorModifier)
1719 propJSON (Proxy :: Proxy DisMaxQuery)
1740 propJSON (Proxy :: Proxy DisMaxQuery)