@@ -7,6 +7,7 @@
7{-# LANGUAGE OverloadedStrings #-}
7{-# LANGUAGE OverloadedStrings #-}
8{-# LANGUAGE RecordWildCards #-}
8{-# LANGUAGE RecordWildCards #-}
9{-# LANGUAGE ScopedTypeVariables #-}
9{-# LANGUAGE ScopedTypeVariables #-}
10+{-# LANGUAGE TemplateHaskell #-}
10{-# LANGUAGE TypeOperators #-}
11{-# LANGUAGE TypeOperators #-}
11{-# OPTIONS_GHC -fno-warn-orphans #-}
12{-# OPTIONS_GHC -fno-warn-orphans #-}
12#if __GLASGOW_HASKELL__ < 800
13#if __GLASGOW_HASKELL__ < 800
@@ -24,6 +25,7 @@ import Control.Monad
24import Control.Monad.Catch
25import Control.Monad.Catch
25import Control.Monad.Reader
26import Control.Monad.Reader
26import Data.Aeson
27import Data.Aeson
27import Data.Aeson.Types (parseEither)
29import Data.Aeson.Types (parseEither)
28import qualified Data.ByteString.Lazy.Char8 as BL8
30import qualified Data.ByteString.Lazy.Char8 as BL8
29import qualified Data.HashMap.Strict as HM
31import qualified Data.HashMap.Strict as HM
@@ -44,7 +46,6 @@ import Data.Typeable
44import qualified Data.Vector as V
46import qualified Data.Vector as V
45import qualified Data.Version as Vers
47import qualified Data.Version as Vers
46import Database.V5.Bloodhound
48import Database.V5.Bloodhound
47−-- import GHC.Generics as G
48import Network.HTTP.Client hiding (Proxy)
49import Network.HTTP.Client hiding (Proxy)
49import qualified Network.HTTP.Types.Method as NHTM
50import qualified Network.HTTP.Types.Method as NHTM
50import qualified Network.HTTP.Types.Status as NHTS
51import qualified Network.HTTP.Types.Status as NHTS
@@ -57,9 +58,8 @@ import Test.QuickCheck.Property.Monoid (T (..), eq, prop_Monoid)
58import Test.Hspec.QuickCheck (prop)
59import Test.Hspec.QuickCheck (prop)
59import Test.QuickCheck
60import Test.QuickCheck
60−
61+import Test.QuickCheck.TH.Generators
61−import qualified Generics.SOP as SOP
62+import Text.Pretty.Simple (pPrint)
62−import qualified Generics.SOP.GGP as SOP
64testServer :: Server
64testServer :: Server
65testServer = Server "http://localhost:9200"
65testServer = Server "http://localhost:9200"
@@ -153,13 +153,19 @@ is v = getServerVersion >>= \x -> return $ x == Just v
153when' :: Monad m => m Bool -> m () -> m ()
153when' :: Monad m => m Bool -> m () -> m ()
154when' b f = b >>= \x -> when x f
154when' b f = b >>= \x -> when x f
156−(==~) :: (ApproxEq a) => a -> a -> Property
156+propJSON :: forall a
157−a ==~ b = counterexample (showApproxEq a ++ " !=~ " ++ showApproxEq b) (a =~ b)
157+ . ( Arbitrary a
159−propJSON :: forall a. (Arbitrary a, ToJSON a, FromJSON a, Show a, ApproxEq a, Typeable a) => Proxy a -> Spec
159+ , FromJSON a
160propJSON _ = prop testName $ \(a :: a) ->
165propJSON _ = prop testName $ \(a :: a) ->
161 let jsonStr = "via " <> BL8.unpack (encode a)
166 let jsonStr = "via " <> BL8.unpack (encode a)
162− in counterexample jsonStr (parseEither parseJSON (toJSON a) ==~ Right a)
167+ in counterexample jsonStr (parseEither parseJSON (toJSON a)
163 where testName = show ty <> " FromJSON/ToJSON roundtrips"
169 where testName = show ty <> " FromJSON/ToJSON roundtrips"
164 ty = typeOf (undefined :: a)
170 ty = typeOf (undefined :: a)
@@ -174,14 +180,8 @@ data Tweet = Tweet { user :: Text
174 , extra :: Maybe Text }
180 , extra :: Maybe Text }
175 deriving (Eq, Show)
181 deriving (Eq, Show)
177−instance ToJSON Tweet where
178− toJSON = genericToJSON defaultOptions
183+$(deriveJSON defaultOptions ''Location)
179−instance FromJSON Tweet where
180− parseJSON = genericParseJSON defaultOptions
181−instance ToJSON Location where
182− toJSON = genericToJSON defaultOptions
184+$(deriveJSON defaultOptions ''Tweet)
183−instance FromJSON Location where
184− parseJSON = genericParseJSON defaultOptions
186data ParentMapping = ParentMapping deriving (Eq, Show)
186data ParentMapping = ParentMapping deriving (Eq, Show)
@@ -433,208 +433,63 @@ withSnapshot srn sn = bracket_ alloc free
436−data BulkTest = BulkTest { name :: Text } deriving (Eq, Show)
437+ BulkTest { name :: Text }
437−instance FromJSON BulkTest where
438+ deriving (Eq, Show, FromJSON, ToJSON)
438− parseJSON = genericParseJSON defaultOptions
439−instance ToJSON BulkTest where
440− toJSON = genericToJSON defaultOptions
442−class GApproxEq f where
443− gApproxEq :: f a -> f a -> Bool
446−instance GApproxEq U1 where
447− gApproxEq U1 U1 = True
449−-- | Sum type, ensure same constructors, recurse
450−instance (GApproxEq a, GApproxEq b) => GApproxEq (a :+: b) where
451− gApproxEq (L1 a) (L1 b) = gApproxEq a b
452− gApproxEq (R1 a) (R1 b) = gApproxEq a b
453− gApproxEq _ _ = False
455−-- | Product type, ensure each field is approx eq
456−instance (GApproxEq a, GApproxEq b) => GApproxEq (a :*: b) where
457− gApproxEq (a1 :*: b1) (a2 :*: b2) = gApproxEq a1 a2 && gApproxEq b1 b2
459−-- | Value type, actually check the values for approx equality
460−instance (ApproxEq a) => GApproxEq (K1 i a) where
461− gApproxEq (K1 a) (K1 b) = a =~ b
463−instance (GApproxEq f) => GApproxEq (M1 i t f) where
464− gApproxEq (M1 a) (M1 b) = gApproxEq a b
466-- | Typeclass for "equal where it matters". Use this to specify
440-- | Typeclass for "equal where it matters". Use this to specify
467-- less-strict equivalence for things such as lists that can wind up
441-- less-strict equivalence for things such as lists that can wind up
468-- in an unpredictable order
442-- in an unpredictable order
469class ApproxEq a where
443class ApproxEq a where
470 (=~) :: a -> a -> Bool
444 (=~) :: a -> a -> Bool
471− default (=~) :: (Generic a, GApproxEq (Rep a)) => a -> a -> Bool
472− a =~ b = gApproxEq (G.from a) (G.from b)
474 showApproxEq :: a -> String
446 showApproxEq :: a -> String
475 default showApproxEq :: (Show a) => a -> String
447 default showApproxEq :: (Show a) => a -> String
476 showApproxEq = show
448 showApproxEq = show
450+(==~) :: (ApproxEq a) => a -> a -> Property
451+a ==~ b = counterexample (showApproxEq a ++ " !=~ " ++ showApproxEq b) (a =~ b)
453+propApproxJSON :: forall a
462+propApproxJSON _ = prop testName $ \(a :: a) ->
463+ let jsonStr = "via " <> BL8.unpack (encode a)
464+ in counterexample jsonStr (parseEither parseJSON (toJSON a)
466+ where testName = show ty <> " FromJSON/ToJSON roundtrips"
467+ ty = typeOf (undefined :: a)
478instance ApproxEq NominalDiffTime where (=~) = (==)
469instance ApproxEq NominalDiffTime where (=~) = (==)
479−instance ApproxEq UTCTime where (=~) = (==)
480−instance ApproxEq Text where (=~) = (==)
481instance ApproxEq Bool where (=~) = (==)
470instance ApproxEq Bool where (=~) = (==)
482instance ApproxEq Int where (=~) = (==)
471instance ApproxEq Int where (=~) = (==)
483−instance ApproxEq Double where (=~) = (==)
472+instance (Eq a, Show a) => ApproxEq (Maybe a) where (=~) = (==)
484−instance (ApproxEq a, Show a) => ApproxEq (NonEmpty a)
485−instance (ApproxEq a, Show a) => ApproxEq (Maybe a)
486−instance ApproxEq GeoPoint
487−instance ApproxEq Regexp
488−instance ApproxEq RangeValue
489−instance ApproxEq LessThan
490−instance ApproxEq LessThanEq
491−instance ApproxEq LessThanD
492−instance ApproxEq LessThanEqD
493−instance ApproxEq GreaterThan
494−instance ApproxEq GreaterThanEq
495−instance ApproxEq GreaterThanD
496−instance ApproxEq GreaterThanEqD
497−instance ApproxEq MinimumMatchHighLow
498−instance ApproxEq RegexpFlag
499−instance ApproxEq RegexpFlags
500−instance ApproxEq NullValue
501−instance ApproxEq Version
502−instance ApproxEq VersionNumber
503−instance ApproxEq DistanceRange
504−instance ApproxEq IndexName
505−instance ApproxEq MappingName
506−instance ApproxEq DocId
507−instance ApproxEq IndexAliasRouting
508−instance ApproxEq RoutingValue
509−instance ApproxEq ShardCount
510−instance ApproxEq ReplicaCount
511−instance ApproxEq TemplateName
512−instance ApproxEq TemplatePattern
513−instance ApproxEq QueryString
514−instance ApproxEq FieldName
515−instance ApproxEq CacheName
516−instance ApproxEq CacheKey
517−instance ApproxEq Existence
518−instance ApproxEq CutoffFrequency
519−instance ApproxEq Analyzer
520−instance ApproxEq Lenient
521−instance ApproxEq Tiebreaker
522−instance ApproxEq Boost
523−instance ApproxEq BoostTerms
524−instance ApproxEq MaxExpansions
525−instance ApproxEq MinimumMatch
526−instance ApproxEq DisableCoord
527−instance ApproxEq IgnoreTermFrequency
528−instance ApproxEq MinimumTermFrequency
529−instance ApproxEq MaxQueryTerms
530−instance ApproxEq Fuzziness
531−instance ApproxEq PrefixLength
532−instance ApproxEq TypeName
533−instance ApproxEq PercentMatch
534−instance ApproxEq StopWord
535−instance ApproxEq QueryPath
536−instance ApproxEq AllowLeadingWildcard
537−instance ApproxEq LowercaseExpanded
538−instance ApproxEq EnablePositionIncrements
539−instance ApproxEq AnalyzeWildcard
540−instance ApproxEq GeneratePhraseQueries
541−instance ApproxEq Locale
542−instance ApproxEq MaxWordLength
543−instance ApproxEq MinWordLength
544−instance ApproxEq PhraseSlop
545−instance ApproxEq MinDocFrequency
546−instance ApproxEq MaxDocFrequency
547−instance ApproxEq Filter
548−instance ApproxEq Query
549−instance ApproxEq SimpleQueryStringQuery
550−instance ApproxEq FieldOrFields
551−instance ApproxEq SimpleQueryFlag
552−instance ApproxEq RegexpQuery
553−instance ApproxEq QueryStringQuery
554−instance ApproxEq RangeQuery
555−instance ApproxEq PrefixQuery
556−instance ApproxEq NestedQuery
557−instance ApproxEq MoreLikeThisFieldQuery
558−instance ApproxEq MoreLikeThisQuery
559−instance ApproxEq IndicesQuery
560−instance ApproxEq HasParentQuery
561−instance ApproxEq HasChildQuery
562−instance ApproxEq FuzzyQuery
563−instance ApproxEq FuzzyLikeFieldQuery
564−instance ApproxEq FuzzyLikeThisQuery
565−instance ApproxEq DisMaxQuery
566−instance ApproxEq CommonTermsQuery
567−instance ApproxEq CommonMinimumMatch
568−instance ApproxEq BoostingQuery
569−instance ApproxEq BoolQuery
570−instance ApproxEq MatchQuery
571−instance ApproxEq MultiMatchQueryType
572−instance ApproxEq BooleanOperator
573−instance ApproxEq ZeroTermsQuery
574−instance ApproxEq MatchQueryType
575−instance ApproxEq AliasRouting
576−instance ApproxEq IndexAliasCreate
577−instance ApproxEq SearchAliasRouting
578−instance ApproxEq ScoreType
579−instance ApproxEq Distance
580−instance ApproxEq DistanceUnit
581−instance ApproxEq DistanceType
582−instance ApproxEq OptimizeBbox
583−instance ApproxEq GeoBoundingBoxConstraint
584−instance ApproxEq GeoFilterType
585−instance ApproxEq GeoBoundingBox
586−instance ApproxEq LatLon
587−instance ApproxEq RangeExecution
588−instance ApproxEq FSType
589−instance ApproxEq CompoundFormat
590−instance ApproxEq InitialShardCount
591−instance ApproxEq Bytes
592−instance ApproxEq ReplicaBounds
593−instance ApproxEq Term
594−instance ApproxEq BoolMatch
595−instance ApproxEq MultiMatchQuery
596−instance ApproxEq IndexSettings
597−instance ApproxEq AllocationPolicy
598instance ApproxEq Char where
473instance ApproxEq Char where
599 (=~) = (==)
474 (=~) = (==)
600−instance ApproxEq Vers.Version where
476+instance ApproxEq NodeAttrFilter where (=~) = (==)
601− (=~) = (==)
477+instance ApproxEq NodeAttrName where (=~) = (==)
602−instance (ApproxEq a, Show a) => ApproxEq [a] where
478+instance (Eq a, Show a) => ApproxEq (NonEmpty a) where (=~) = (==)
603− as =~ bs = and (zipWith (=~) as bs)
604instance (ApproxEq l, Show l, ApproxEq r, Show r) => ApproxEq (Either l r) where
479instance (ApproxEq l, Show l, ApproxEq r, Show r) => ApproxEq (Either l r) where
605 Left a =~ Left b = a =~ b
480 Left a =~ Left b = a =~ b
606 Right a =~ Right b = a =~ b
481 Right a =~ Right b = a =~ b
607 _ =~ _ = False
482 _ =~ _ = False
608 showApproxEq (Left x) = "Left " <> showApproxEq x
483 showApproxEq (Left x) = "Left " <> showApproxEq x
609 showApproxEq (Right x) = "Right " <> showApproxEq x
484 showApproxEq (Right x) = "Right " <> showApproxEq x
610−instance ApproxEq NodeAttrFilter
485+instance (ApproxEq a, Show a) => ApproxEq [a] where
611−instance ApproxEq NodeAttrName
486+ as =~ bs = and (zipWith (=~) as bs)
612−instance ApproxEq BuildHash
613−instance ApproxEq TemplateQueryKeyValuePairs where
615−instance ApproxEq TemplateQueryInline
616−instance ApproxEq Size
617−instance ApproxEq PhraseSuggesterHighlighter
618−instance ApproxEq PhraseSuggesterCollate
487+instance ApproxEq ReplicaCount where (=~) = (==)
619−instance ApproxEq PhraseSuggester
620−instance ApproxEq SuggestType
621−instance ApproxEq Suggest
488+instance ApproxEq ReplicaBounds where (=~) = (==)
623−-- | Due to the way nodeattrfilters get serialized here, they may come
624−-- out in a different order, but they are morally equivalent
625−instance ApproxEq UpdatableIndexSetting where
489+instance ApproxEq Bytes where (=~) = (==)
626− RoutingAllocationInclude a =~ RoutingAllocationInclude b =
490+instance ApproxEq AllocationPolicy where (=~) = (==)
627− NE.sort a =~ NE.sort b
491+instance ApproxEq InitialShardCount where (=~) = (==)
628− RoutingAllocationExclude a =~ RoutingAllocationExclude b =
492+instance ApproxEq FSType where (=~) = (==)
629− NE.sort a =~ NE.sort b
630− RoutingAllocationRequire a =~ RoutingAllocationRequire b =
631− NE.sort a =~ NE.sort b
633− showApproxEq (RoutingAllocationInclude xs) = show (RoutingAllocationInclude (NE.sort xs))
634− showApproxEq (RoutingAllocationExclude xs) = show (RoutingAllocationExclude (NE.sort xs))
635− showApproxEq (RoutingAllocationRequire xs) = show (RoutingAllocationRequire (NE.sort xs))
636− showApproxEq x = show x
639noDuplicates :: Eq a => [a] -> Bool
494noDuplicates :: Eq a => [a] -> Bool
640noDuplicates xs = nub xs == xs
495noDuplicates xs = nub xs == xs
@@ -674,7 +529,7 @@ instance (Arbitrary a, Typeable a) => Arbitrary (Hit a) where
674 <*> arbitraryScore
529 <*> arbitraryScore
675 <*> arbitrary
530 <*> arbitrary
676 <*> arbitrary
531 <*> arbitrary
677− shrink = genericShrink
532+
680instance (Arbitrary a, Typeable a) => Arbitrary (SearchHits a) where
535instance (Arbitrary a, Typeable a) => Arbitrary (SearchHits a) where
@@ -683,7 +538,7 @@ instance (Arbitrary a, Typeable a) => Arbitrary (SearchHits a) where
683 score <- arbitraryScore
538 score <- arbitraryScore
684 hs <- arbitrary
539 hs <- arbitrary
685 return $ SearchHits tot score hs
540 return $ SearchHits tot score hs
686− shrink = genericShrink
541+
688reduceSize :: Gen a -> Gen a
543reduceSize :: Gen a -> Gen a
689reduceSize f = sized $ \n -> resize (n `div` 2) f
544reduceSize f = sized $ \n -> resize (n `div` 2) f
@@ -721,12 +576,14 @@ instance Arbitrary AliasRouting where
721 <$> (Just <$> arbitrary)
576 <$> (Just <$> arbitrary)
722 <*> (Just <$> arbitrary)
577 <*> (Just <$> arbitrary)
723 allAlias = AllAliasRouting <$> arbitrary
578 allAlias = AllAliasRouting <$> arbitrary
724− shrink = genericShrink
579+
727instance Arbitrary FieldName where
582instance Arbitrary FieldName where
728− arbitrary = FieldName . T.pack <$> listOf1 arbitraryAlphaNum
586+ <$> listOf1 arbitraryAlphaNum
729− shrink = genericShrink
732#if MIN_VERSION_base(4,10,0)
589#if MIN_VERSION_base(4,10,0)
@@ -737,7 +594,9 @@ qcNonEmptyToNonEmpty (NonEmpty (a : xs)) = (a :| xs)
737qcNonEmptyToNonEmpty (NonEmpty []) = error "NonEmpty was empty!"
594qcNonEmptyToNonEmpty (NonEmpty []) = error "NonEmpty was empty!"
739instance Arbitrary a => Arbitrary (NonEmpty a) where
596instance Arbitrary a => Arbitrary (NonEmpty a) where
740− arbitrary = qcNonEmptyToNonEmpty <$> arbitrary
598+ qcNonEmptyToNonEmpty
743instance Arbitrary RegexpFlags where
602instance Arbitrary RegexpFlags where
@@ -745,62 +604,73 @@ instance Arbitrary RegexpFlags where
745 , pure NoRegexpFlags
604 , pure NoRegexpFlags
746 , SomeRegexpFlags <$> genUniqueFlags
605 , SomeRegexpFlags <$> genUniqueFlags
748− where genUniqueFlags = NE.fromList . nub <$> listOf1 arbitrary
607+ where genUniqueFlags =
749−
608+ NE.fromList . nub
750− shrink = genericShrink
609+ <$> listOf1 arbitrary
753instance Arbitrary IndexAliasCreate where
611instance Arbitrary IndexAliasCreate where
754− arbitrary = IndexAliasCreate <$> arbitrary <*> reduceSize arbitrary
615+ <*> reduceSize arbitrary
755− shrink = genericShrink
757instance Arbitrary Query where
617instance Arbitrary Query where
758− arbitrary = reduceSize $ oneof [ TermQuery <$> arbitrary <*> arbitrary
620+ $ oneof [ TermQuery <$> arbitrary <*> arbitrary
759− , TermsQuery <$> arbitrary <*> arbitrary
621+ , TermsQuery <$> arbitrary <*> arbitrary
760− , QueryMatchQuery <$> arbitrary
622+ , QueryMatchQuery <$> arbitrary
761− , QueryMultiMatchQuery <$> arbitrary
623+ , QueryMultiMatchQuery <$> arbitrary
762− , QueryBoolQuery <$> arbitrary
624+ , QueryBoolQuery <$> arbitrary
763− , QueryBoostingQuery <$> arbitrary
625+ , QueryBoostingQuery <$> arbitrary
764− , QueryCommonTermsQuery <$> arbitrary
626+ , QueryCommonTermsQuery <$> arbitrary
765− , ConstantScoreQuery <$> arbitrary <*> arbitrary
627+ , ConstantScoreQuery <$> arbitrary <*> arbitrary
766− , QueryDisMaxQuery <$> arbitrary
628+ , QueryDisMaxQuery <$> arbitrary
767− , QueryFuzzyLikeThisQuery <$> arbitrary
629+ , QueryFuzzyLikeThisQuery <$> arbitrary
768− , QueryFuzzyLikeFieldQuery <$> arbitrary
630+ , QueryFuzzyLikeFieldQuery <$> arbitrary
769− , QueryFuzzyQuery <$> arbitrary
631+ , QueryFuzzyQuery <$> arbitrary
770− , QueryHasChildQuery <$> arbitrary
632+ , QueryHasChildQuery <$> arbitrary
771− , QueryHasParentQuery <$> arbitrary
633+ , QueryHasParentQuery <$> arbitrary
772− , IdsQuery <$> arbitrary <*> arbitrary
634+ , IdsQuery <$> arbitrary <*> arbitrary
773− , QueryIndicesQuery <$> arbitrary
635+ , QueryIndicesQuery <$> arbitrary
774− , MatchAllQuery <$> arbitrary
636+ , MatchAllQuery <$> arbitrary
775− , QueryMoreLikeThisQuery <$> arbitrary
637+ , QueryMoreLikeThisQuery <$> arbitrary
776− , QueryMoreLikeThisFieldQuery <$> arbitrary
638+ , QueryMoreLikeThisFieldQuery <$> arbitrary
777− , QueryNestedQuery <$> arbitrary
639+ , QueryNestedQuery <$> arbitrary
778− , QueryPrefixQuery <$> arbitrary
640+ , QueryPrefixQuery <$> arbitrary
779− , QueryQueryStringQuery <$> arbitrary
641+ , QueryQueryStringQuery <$> arbitrary
780− , QuerySimpleQueryStringQuery <$> arbitrary
642+ , QuerySimpleQueryStringQuery <$> arbitrary
781− , QueryRangeQuery <$> arbitrary
643+ , QueryRangeQuery <$> arbitrary
782− , QueryRegexpQuery <$> arbitrary
644+ , QueryRegexpQuery <$> arbitrary
783− , QueryTemplateQueryInline <$> arbitrary
645+ , QueryTemplateQueryInline <$> arbitrary
647+ -- TODO: Implement shrink
785− shrink = genericShrink
648+ -- shrink = genericShrink
787instance Arbitrary Filter where
650instance Arbitrary Filter where
788− arbitrary = Filter <$> arbitrary
652+ Filter <$> arbitrary
789− shrink = genericShrink
653+ shrink (Filter q) =
791instance Arbitrary ReplicaBounds where
656instance Arbitrary ReplicaBounds where
792 arbitrary = oneof [ replicasBounded
657 arbitrary = oneof [ replicasBounded
793 , replicasLowerBounded
658 , replicasLowerBounded
794 , pure ReplicasUnbounded
659 , pure ReplicasUnbounded
796− where replicasBounded = do Positive a <- arbitrary
661+ where replicasBounded = do
662+ Positive a <- arbitrary
797− Positive b <- arbitrary
663+ Positive b <- arbitrary
798− return (ReplicasBounded a b)
664+ return (ReplicasBounded a b)
799− replicasLowerBounded = do Positive a <- arbitrary
665+ replicasLowerBounded = do
666+ Positive a <- arbitrary
800− return (ReplicasLowerBounded a)
667+ return (ReplicasLowerBounded a)
802instance Arbitrary NodeAttrName where
669instance Arbitrary NodeAttrName where
803− arbitrary = NodeAttrName . T.pack <$> listOf1 arbitraryAlphaNum
673+ <$> listOf1 arbitraryAlphaNum
806instance Arbitrary NodeAttrFilter where
676instance Arbitrary NodeAttrFilter where
@@ -809,7 +679,6 @@ instance Arbitrary NodeAttrFilter where
809 s:ss <- listOf1 (listOf1 arbitraryAlphaNum)
679 s:ss <- listOf1 (listOf1 arbitraryAlphaNum)
810 let ts = T.pack <$> s :| ss
680 let ts = T.pack <$> s :| ss
811 return (NodeAttrFilter n ts)
681 return (NodeAttrFilter n ts)
812− shrink = genericShrink
814instance Arbitrary VersionNumber where
683instance Arbitrary VersionNumber where
815 arbitrary = mk . fmap getPositive . getNonEmpty <$> arbitrary
684 arbitrary = mk . fmap getPositive . getNonEmpty <$> arbitrary
@@ -820,142 +689,285 @@ instance Arbitrary TemplateQueryKeyValuePairs where
820 arbitrary = TemplateQueryKeyValuePairs . HM.fromList <$> arbitrary
689 arbitrary = TemplateQueryKeyValuePairs . HM.fromList <$> arbitrary
821 shrink (TemplateQueryKeyValuePairs x) = map (TemplateQueryKeyValuePairs . HM.fromList) . shrink $ HM.toList x
690 shrink (TemplateQueryKeyValuePairs x) = map (TemplateQueryKeyValuePairs . HM.fromList) . shrink $ HM.toList x
692+makeArbitrary ''IndexName
823−instance Arbitrary IndexName where arbitrary = sopArbitrary; shrink = genericShrink
693+instance Arbitrary IndexName where arbitrary = arbitraryIndexName
694+makeArbitrary ''MappingName
824−instance Arbitrary MappingName where arbitrary = sopArbitrary; shrink = genericShrink
695+instance Arbitrary MappingName where arbitrary = arbitraryMappingName
696+makeArbitrary ''DocId
825−instance Arbitrary DocId where arbitrary = sopArbitrary; shrink = genericShrink
697+instance Arbitrary DocId where arbitrary = arbitraryDocId
698+makeArbitrary ''Version
826−instance Arbitrary Version where arbitrary = sopArbitrary; shrink = genericShrink
699+instance Arbitrary Version where arbitrary = arbitraryVersion
700+makeArbitrary ''BuildHash
827−instance Arbitrary BuildHash where arbitrary = sopArbitrary; shrink = genericShrink
701+instance Arbitrary BuildHash where arbitrary = arbitraryBuildHash
702+makeArbitrary ''IndexAliasRouting
828−instance Arbitrary IndexAliasRouting where arbitrary = sopArbitrary; shrink = genericShrink
703+instance Arbitrary IndexAliasRouting where arbitrary = arbitraryIndexAliasRouting
704+makeArbitrary ''ShardCount
829−instance Arbitrary ShardCount where arbitrary = sopArbitrary; shrink = genericShrink
705+instance Arbitrary ShardCount where arbitrary = arbitraryShardCount
706+makeArbitrary ''ReplicaCount
830−instance Arbitrary ReplicaCount where arbitrary = sopArbitrary; shrink = genericShrink
707+instance Arbitrary ReplicaCount where arbitrary = arbitraryReplicaCount
708+makeArbitrary ''TemplateName
831−instance Arbitrary TemplateName where arbitrary = sopArbitrary; shrink = genericShrink
709+instance Arbitrary TemplateName where arbitrary = arbitraryTemplateName
710+makeArbitrary ''TemplatePattern
832−instance Arbitrary TemplatePattern where arbitrary = sopArbitrary; shrink = genericShrink
711+instance Arbitrary TemplatePattern where arbitrary = arbitraryTemplatePattern
712+makeArbitrary ''QueryString
833−instance Arbitrary QueryString where arbitrary = sopArbitrary; shrink = genericShrink
713+instance Arbitrary QueryString where arbitrary = arbitraryQueryString
714+makeArbitrary ''CacheName
834−instance Arbitrary CacheName where arbitrary = sopArbitrary; shrink = genericShrink
715+instance Arbitrary CacheName where arbitrary = arbitraryCacheName
716+makeArbitrary ''CacheKey
835−instance Arbitrary CacheKey where arbitrary = sopArbitrary; shrink = genericShrink
717+instance Arbitrary CacheKey where arbitrary = arbitraryCacheKey
718+makeArbitrary ''Existence
836−instance Arbitrary Existence where arbitrary = sopArbitrary; shrink = genericShrink
719+instance Arbitrary Existence where arbitrary = arbitraryExistence
720+makeArbitrary ''CutoffFrequency
837−instance Arbitrary CutoffFrequency where arbitrary = sopArbitrary; shrink = genericShrink
721+instance Arbitrary CutoffFrequency where arbitrary = arbitraryCutoffFrequency
722+makeArbitrary ''Analyzer
838−instance Arbitrary Analyzer where arbitrary = sopArbitrary; shrink = genericShrink
723+instance Arbitrary Analyzer where arbitrary = arbitraryAnalyzer
724+makeArbitrary ''MaxExpansions
839−instance Arbitrary MaxExpansions where arbitrary = sopArbitrary; shrink = genericShrink
725+instance Arbitrary MaxExpansions where arbitrary = arbitraryMaxExpansions
726+makeArbitrary ''Lenient
840−instance Arbitrary Lenient where arbitrary = sopArbitrary; shrink = genericShrink
727+instance Arbitrary Lenient where arbitrary = arbitraryLenient
728+makeArbitrary ''Tiebreaker
841−instance Arbitrary Tiebreaker where arbitrary = sopArbitrary; shrink = genericShrink
729+instance Arbitrary Tiebreaker where arbitrary = arbitraryTiebreaker
730+makeArbitrary ''Boost
842−instance Arbitrary Boost where arbitrary = sopArbitrary; shrink = genericShrink
731+instance Arbitrary Boost where arbitrary = arbitraryBoost
732+makeArbitrary ''BoostTerms
843−instance Arbitrary BoostTerms where arbitrary = sopArbitrary; shrink = genericShrink
733+instance Arbitrary BoostTerms where arbitrary = arbitraryBoostTerms
734+makeArbitrary ''MinimumMatch
844−instance Arbitrary MinimumMatch where arbitrary = sopArbitrary; shrink = genericShrink
735+instance Arbitrary MinimumMatch where arbitrary = arbitraryMinimumMatch
736+makeArbitrary ''DisableCoord
845−instance Arbitrary DisableCoord where arbitrary = sopArbitrary; shrink = genericShrink
737+instance Arbitrary DisableCoord where arbitrary = arbitraryDisableCoord
738+makeArbitrary ''IgnoreTermFrequency
846−instance Arbitrary IgnoreTermFrequency where arbitrary = sopArbitrary; shrink = genericShrink
739+instance Arbitrary IgnoreTermFrequency where arbitrary = arbitraryIgnoreTermFrequency
740+makeArbitrary ''MinimumTermFrequency
847−instance Arbitrary MinimumTermFrequency where arbitrary = sopArbitrary; shrink = genericShrink
741+instance Arbitrary MinimumTermFrequency where arbitrary = arbitraryMinimumTermFrequency
742+makeArbitrary ''MaxQueryTerms
848−instance Arbitrary MaxQueryTerms where arbitrary = sopArbitrary; shrink = genericShrink
743+instance Arbitrary MaxQueryTerms where arbitrary = arbitraryMaxQueryTerms
744+makeArbitrary ''Fuzziness
849−instance Arbitrary Fuzziness where arbitrary = sopArbitrary; shrink = genericShrink
745+instance Arbitrary Fuzziness where arbitrary = arbitraryFuzziness
746+makeArbitrary ''PrefixLength
850−instance Arbitrary PrefixLength where arbitrary = sopArbitrary; shrink = genericShrink
747+instance Arbitrary PrefixLength where arbitrary = arbitraryPrefixLength
748+makeArbitrary ''TypeName
851−instance Arbitrary TypeName where arbitrary = sopArbitrary; shrink = genericShrink
749+instance Arbitrary TypeName where arbitrary = arbitraryTypeName
750+makeArbitrary ''PercentMatch
852−instance Arbitrary PercentMatch where arbitrary = sopArbitrary; shrink = genericShrink
751+instance Arbitrary PercentMatch where arbitrary = arbitraryPercentMatch
752+makeArbitrary ''StopWord
853−instance Arbitrary StopWord where arbitrary = sopArbitrary; shrink = genericShrink
753+instance Arbitrary StopWord where arbitrary = arbitraryStopWord
754+makeArbitrary ''QueryPath
854−instance Arbitrary QueryPath where arbitrary = sopArbitrary; shrink = genericShrink
755+instance Arbitrary QueryPath where arbitrary = arbitraryQueryPath
756+makeArbitrary ''AllowLeadingWildcard
855−instance Arbitrary AllowLeadingWildcard where arbitrary = sopArbitrary; shrink = genericShrink
757+instance Arbitrary AllowLeadingWildcard where arbitrary = arbitraryAllowLeadingWildcard
758+makeArbitrary ''LowercaseExpanded
856−instance Arbitrary LowercaseExpanded where arbitrary = sopArbitrary; shrink = genericShrink
759+instance Arbitrary LowercaseExpanded where arbitrary = arbitraryLowercaseExpanded
760+makeArbitrary ''EnablePositionIncrements
857−instance Arbitrary EnablePositionIncrements where arbitrary = sopArbitrary; shrink = genericShrink
761+instance Arbitrary EnablePositionIncrements where arbitrary = arbitraryEnablePositionIncrements
762+makeArbitrary ''AnalyzeWildcard
858−instance Arbitrary AnalyzeWildcard where arbitrary = sopArbitrary; shrink = genericShrink
763+instance Arbitrary AnalyzeWildcard where arbitrary = arbitraryAnalyzeWildcard
764+makeArbitrary ''GeneratePhraseQueries
859−instance Arbitrary GeneratePhraseQueries where arbitrary = sopArbitrary; shrink = genericShrink
765+instance Arbitrary GeneratePhraseQueries where arbitrary = arbitraryGeneratePhraseQueries
766+makeArbitrary ''Locale
860−instance Arbitrary Locale where arbitrary = sopArbitrary; shrink = genericShrink
767+instance Arbitrary Locale where arbitrary = arbitraryLocale
768+makeArbitrary ''MaxWordLength
861−instance Arbitrary MaxWordLength where arbitrary = sopArbitrary; shrink = genericShrink
769+instance Arbitrary MaxWordLength where arbitrary = arbitraryMaxWordLength
770+makeArbitrary ''MinWordLength
862−instance Arbitrary MinWordLength where arbitrary = sopArbitrary; shrink = genericShrink
771+instance Arbitrary MinWordLength where arbitrary = arbitraryMinWordLength
772+makeArbitrary ''PhraseSlop
863−instance Arbitrary PhraseSlop where arbitrary = sopArbitrary; shrink = genericShrink
773+instance Arbitrary PhraseSlop where arbitrary = arbitraryPhraseSlop
774+makeArbitrary ''MinDocFrequency
864−instance Arbitrary MinDocFrequency where arbitrary = sopArbitrary; shrink = genericShrink
775+instance Arbitrary MinDocFrequency where arbitrary = arbitraryMinDocFrequency
776+makeArbitrary ''MaxDocFrequency
865−instance Arbitrary MaxDocFrequency where arbitrary = sopArbitrary; shrink = genericShrink
777+instance Arbitrary MaxDocFrequency where arbitrary = arbitraryMaxDocFrequency
778+makeArbitrary ''Regexp
866−instance Arbitrary Regexp where arbitrary = sopArbitrary; shrink = genericShrink
779+instance Arbitrary Regexp where arbitrary = arbitraryRegexp
780+makeArbitrary ''SimpleQueryStringQuery
867−instance Arbitrary SimpleQueryStringQuery where arbitrary = sopArbitrary; shrink = genericShrink
781+instance Arbitrary SimpleQueryStringQuery where arbitrary = arbitrarySimpleQueryStringQuery
782+makeArbitrary ''FieldOrFields
868−instance Arbitrary FieldOrFields where arbitrary = sopArbitrary; shrink = genericShrink
783+instance Arbitrary FieldOrFields where arbitrary = arbitraryFieldOrFields
784+makeArbitrary ''SimpleQueryFlag
869−instance Arbitrary SimpleQueryFlag where arbitrary = sopArbitrary; shrink = genericShrink
785+instance Arbitrary SimpleQueryFlag where arbitrary = arbitrarySimpleQueryFlag
786+makeArbitrary ''RegexpQuery
870−instance Arbitrary RegexpQuery where arbitrary = sopArbitrary; shrink = genericShrink
787+instance Arbitrary RegexpQuery where arbitrary = arbitraryRegexpQuery
788+makeArbitrary ''QueryStringQuery
871−instance Arbitrary QueryStringQuery where arbitrary = sopArbitrary; shrink = genericShrink
789+instance Arbitrary QueryStringQuery where arbitrary = arbitraryQueryStringQuery
790+makeArbitrary ''RangeQuery
872−instance Arbitrary RangeQuery where arbitrary = sopArbitrary; shrink = genericShrink
791+instance Arbitrary RangeQuery where arbitrary = arbitraryRangeQuery
792+makeArbitrary ''RangeValue
873−instance Arbitrary RangeValue where arbitrary = sopArbitrary; shrink = genericShrink
793+instance Arbitrary RangeValue where arbitrary = arbitraryRangeValue
794+makeArbitrary ''PrefixQuery
874−instance Arbitrary PrefixQuery where arbitrary = sopArbitrary; shrink = genericShrink
795+instance Arbitrary PrefixQuery where arbitrary = arbitraryPrefixQuery
796+makeArbitrary ''NestedQuery
875−instance Arbitrary NestedQuery where arbitrary = sopArbitrary; shrink = genericShrink
797+instance Arbitrary NestedQuery where arbitrary = arbitraryNestedQuery
798+makeArbitrary ''MoreLikeThisFieldQuery
876−instance Arbitrary MoreLikeThisFieldQuery where arbitrary = sopArbitrary; shrink = genericShrink
799+instance Arbitrary MoreLikeThisFieldQuery where arbitrary = arbitraryMoreLikeThisFieldQuery
800+makeArbitrary ''MoreLikeThisQuery
877−instance Arbitrary MoreLikeThisQuery where arbitrary = sopArbitrary; shrink = genericShrink
801+instance Arbitrary MoreLikeThisQuery where arbitrary = arbitraryMoreLikeThisQuery
802+makeArbitrary ''IndicesQuery
878−instance Arbitrary IndicesQuery where arbitrary = sopArbitrary; shrink = genericShrink
803+instance Arbitrary IndicesQuery where arbitrary = arbitraryIndicesQuery
804+makeArbitrary ''HasParentQuery
879−instance Arbitrary HasParentQuery where arbitrary = sopArbitrary; shrink = genericShrink
805+instance Arbitrary HasParentQuery where arbitrary = arbitraryHasParentQuery
806+makeArbitrary ''HasChildQuery
880−instance Arbitrary HasChildQuery where arbitrary = sopArbitrary; shrink = genericShrink
807+instance Arbitrary HasChildQuery where arbitrary = arbitraryHasChildQuery
808+makeArbitrary ''FuzzyQuery
881−instance Arbitrary FuzzyQuery where arbitrary = sopArbitrary; shrink = genericShrink
809+instance Arbitrary FuzzyQuery where arbitrary = arbitraryFuzzyQuery
810+makeArbitrary ''FuzzyLikeFieldQuery
882−instance Arbitrary FuzzyLikeFieldQuery where arbitrary = sopArbitrary; shrink = genericShrink
811+instance Arbitrary FuzzyLikeFieldQuery where arbitrary = arbitraryFuzzyLikeFieldQuery
812+makeArbitrary ''FuzzyLikeThisQuery
883−instance Arbitrary FuzzyLikeThisQuery where arbitrary = sopArbitrary; shrink = genericShrink
813+instance Arbitrary FuzzyLikeThisQuery where arbitrary = arbitraryFuzzyLikeThisQuery
814+makeArbitrary ''DisMaxQuery
884−instance Arbitrary DisMaxQuery where arbitrary = sopArbitrary; shrink = genericShrink
815+instance Arbitrary DisMaxQuery where arbitrary = arbitraryDisMaxQuery
816+makeArbitrary ''CommonTermsQuery
885−instance Arbitrary CommonTermsQuery where arbitrary = sopArbitrary; shrink = genericShrink
817+instance Arbitrary CommonTermsQuery where arbitrary = arbitraryCommonTermsQuery
818+makeArbitrary ''DistanceRange
886−instance Arbitrary DistanceRange where arbitrary = sopArbitrary; shrink = genericShrink
819+instance Arbitrary DistanceRange where arbitrary = arbitraryDistanceRange
820+makeArbitrary ''MultiMatchQuery
887−instance Arbitrary MultiMatchQuery where arbitrary = sopArbitrary; shrink = genericShrink
821+instance Arbitrary MultiMatchQuery where arbitrary = arbitraryMultiMatchQuery
822+makeArbitrary ''LessThanD
888−instance Arbitrary LessThanD where arbitrary = sopArbitrary; shrink = genericShrink
823+instance Arbitrary LessThanD where arbitrary = arbitraryLessThanD
824+makeArbitrary ''LessThanEqD
889−instance Arbitrary LessThanEqD where arbitrary = sopArbitrary; shrink = genericShrink
825+instance Arbitrary LessThanEqD where arbitrary = arbitraryLessThanEqD
826+makeArbitrary ''GreaterThanD
890−instance Arbitrary GreaterThanD where arbitrary = sopArbitrary; shrink = genericShrink
827+instance Arbitrary GreaterThanD where arbitrary = arbitraryGreaterThanD
828+makeArbitrary ''GreaterThanEqD
891−instance Arbitrary GreaterThanEqD where arbitrary = sopArbitrary; shrink = genericShrink
829+instance Arbitrary GreaterThanEqD where arbitrary = arbitraryGreaterThanEqD
830+makeArbitrary ''LessThan
892−instance Arbitrary LessThan where arbitrary = sopArbitrary; shrink = genericShrink
831+instance Arbitrary LessThan where arbitrary = arbitraryLessThan
832+makeArbitrary ''LessThanEq
893−instance Arbitrary LessThanEq where arbitrary = sopArbitrary; shrink = genericShrink
833+instance Arbitrary LessThanEq where arbitrary = arbitraryLessThanEq
834+makeArbitrary ''GreaterThan
894−instance Arbitrary GreaterThan where arbitrary = sopArbitrary; shrink = genericShrink
835+instance Arbitrary GreaterThan where arbitrary = arbitraryGreaterThan
836+makeArbitrary ''GreaterThanEq
895−instance Arbitrary GreaterThanEq where arbitrary = sopArbitrary; shrink = genericShrink
837+instance Arbitrary GreaterThanEq where arbitrary = arbitraryGreaterThanEq
838+makeArbitrary ''GeoPoint
896−instance Arbitrary GeoPoint where arbitrary = sopArbitrary; shrink = genericShrink
839+instance Arbitrary GeoPoint where arbitrary = arbitraryGeoPoint
840+makeArbitrary ''NullValue
897−instance Arbitrary NullValue where arbitrary = sopArbitrary; shrink = genericShrink
841+instance Arbitrary NullValue where arbitrary = arbitraryNullValue
842+makeArbitrary ''MinimumMatchHighLow
898−instance Arbitrary MinimumMatchHighLow where arbitrary = sopArbitrary; shrink = genericShrink
843+instance Arbitrary MinimumMatchHighLow where arbitrary = arbitraryMinimumMatchHighLow
844+makeArbitrary ''CommonMinimumMatch
899−instance Arbitrary CommonMinimumMatch where arbitrary = sopArbitrary; shrink = genericShrink
845+instance Arbitrary CommonMinimumMatch where arbitrary = arbitraryCommonMinimumMatch
846+makeArbitrary ''BoostingQuery
900−instance Arbitrary BoostingQuery where arbitrary = sopArbitrary; shrink = genericShrink
847+instance Arbitrary BoostingQuery where arbitrary = arbitraryBoostingQuery
848+makeArbitrary ''BoolQuery
901−instance Arbitrary BoolQuery where arbitrary = sopArbitrary; shrink = genericShrink
849+instance Arbitrary BoolQuery where arbitrary = arbitraryBoolQuery
850+makeArbitrary ''MatchQuery
902−instance Arbitrary MatchQuery where arbitrary = sopArbitrary; shrink = genericShrink
851+instance Arbitrary MatchQuery where arbitrary = arbitraryMatchQuery
852+makeArbitrary ''MultiMatchQueryType
903−instance Arbitrary MultiMatchQueryType where arbitrary = sopArbitrary; shrink = genericShrink
853+instance Arbitrary MultiMatchQueryType where arbitrary = arbitraryMultiMatchQueryType
854+makeArbitrary ''BooleanOperator
904−instance Arbitrary BooleanOperator where arbitrary = sopArbitrary; shrink = genericShrink
855+instance Arbitrary BooleanOperator where arbitrary = arbitraryBooleanOperator
856+makeArbitrary ''ZeroTermsQuery
905−instance Arbitrary ZeroTermsQuery where arbitrary = sopArbitrary; shrink = genericShrink
857+instance Arbitrary ZeroTermsQuery where arbitrary = arbitraryZeroTermsQuery
858+makeArbitrary ''MatchQueryType
906−instance Arbitrary MatchQueryType where arbitrary = sopArbitrary; shrink = genericShrink
859+instance Arbitrary MatchQueryType where arbitrary = arbitraryMatchQueryType
860+makeArbitrary ''SearchAliasRouting
907−instance Arbitrary SearchAliasRouting where arbitrary = sopArbitrary; shrink = genericShrink
861+instance Arbitrary SearchAliasRouting where arbitrary = arbitrarySearchAliasRouting
862+makeArbitrary ''ScoreType
908−instance Arbitrary ScoreType where arbitrary = sopArbitrary; shrink = genericShrink
863+instance Arbitrary ScoreType where arbitrary = arbitraryScoreType
864+makeArbitrary ''Distance
909−instance Arbitrary Distance where arbitrary = sopArbitrary; shrink = genericShrink
865+instance Arbitrary Distance where arbitrary = arbitraryDistance
866+makeArbitrary ''DistanceUnit
910−instance Arbitrary DistanceUnit where arbitrary = sopArbitrary; shrink = genericShrink
867+instance Arbitrary DistanceUnit where arbitrary = arbitraryDistanceUnit
868+makeArbitrary ''DistanceType
911−instance Arbitrary DistanceType where arbitrary = sopArbitrary; shrink = genericShrink
869+instance Arbitrary DistanceType where arbitrary = arbitraryDistanceType
870+makeArbitrary ''OptimizeBbox
912−instance Arbitrary OptimizeBbox where arbitrary = sopArbitrary; shrink = genericShrink
871+instance Arbitrary OptimizeBbox where arbitrary = arbitraryOptimizeBbox
872+makeArbitrary ''GeoBoundingBoxConstraint
913−instance Arbitrary GeoBoundingBoxConstraint where arbitrary = sopArbitrary; shrink = genericShrink
873+instance Arbitrary GeoBoundingBoxConstraint where arbitrary = arbitraryGeoBoundingBoxConstraint
874+makeArbitrary ''GeoFilterType
914−instance Arbitrary GeoFilterType where arbitrary = sopArbitrary; shrink = genericShrink
875+instance Arbitrary GeoFilterType where arbitrary = arbitraryGeoFilterType
876+makeArbitrary ''GeoBoundingBox
915−instance Arbitrary GeoBoundingBox where arbitrary = sopArbitrary; shrink = genericShrink
877+instance Arbitrary GeoBoundingBox where arbitrary = arbitraryGeoBoundingBox
878+makeArbitrary ''LatLon
916−instance Arbitrary LatLon where arbitrary = sopArbitrary; shrink = genericShrink
879+instance Arbitrary LatLon where arbitrary = arbitraryLatLon
880+makeArbitrary ''RangeExecution
917−instance Arbitrary RangeExecution where arbitrary = sopArbitrary; shrink = genericShrink
881+instance Arbitrary RangeExecution where arbitrary = arbitraryRangeExecution
882+makeArbitrary ''RegexpFlag
918−instance Arbitrary RegexpFlag where arbitrary = sopArbitrary; shrink = genericShrink
883+instance Arbitrary RegexpFlag where arbitrary = arbitraryRegexpFlag
884+makeArbitrary ''BoolMatch
919−instance Arbitrary BoolMatch where arbitrary = sopArbitrary; shrink = genericShrink
885+instance Arbitrary BoolMatch where arbitrary = arbitraryBoolMatch
920−instance Arbitrary Term where arbitrary = sopArbitrary; shrink = genericShrink
887+instance Arbitrary Term where arbitrary = arbitraryTerm
888+makeArbitrary ''IndexSettings
921−instance Arbitrary IndexSettings where arbitrary = sopArbitrary; shrink = genericShrink
889+instance Arbitrary IndexSettings where arbitrary = arbitraryIndexSettings
890+makeArbitrary ''TokenChar
922−instance Arbitrary TokenChar where arbitrary = sopArbitrary; shrink = genericShrink
891+instance Arbitrary TokenChar where arbitrary = arbitraryTokenChar
892+makeArbitrary ''Ngram
923−instance Arbitrary Ngram where arbitrary = sopArbitrary; shrink = genericShrink
893+instance Arbitrary Ngram where arbitrary = arbitraryNgram
894+makeArbitrary ''TokenizerDefinition
924−instance Arbitrary TokenizerDefinition where arbitrary = sopArbitrary; shrink = genericShrink
895+instance Arbitrary TokenizerDefinition where arbitrary = arbitraryTokenizerDefinition
896+makeArbitrary ''AnalyzerDefinition
925−instance Arbitrary AnalyzerDefinition where arbitrary = sopArbitrary; shrink = genericShrink
897+instance Arbitrary AnalyzerDefinition where arbitrary = arbitraryAnalyzerDefinition
898+makeArbitrary ''Analysis
926−instance Arbitrary Analysis where arbitrary = sopArbitrary; shrink = genericShrink
899+instance Arbitrary Analysis where arbitrary = arbitraryAnalysis
900+makeArbitrary ''Tokenizer
927−instance Arbitrary Tokenizer where arbitrary = sopArbitrary; shrink = genericShrink
901+instance Arbitrary Tokenizer where arbitrary = arbitraryTokenizer
902+makeArbitrary ''UpdatableIndexSetting
928−instance Arbitrary UpdatableIndexSetting where arbitrary = sopArbitrary; shrink = genericShrink
903+instance Arbitrary UpdatableIndexSetting where
904+ arbitrary = arbitraryUpdatableIndexSetting
905+makeArbitrary ''Compression
929−instance Arbitrary Compression where arbitrary = sopArbitrary; shrink = genericShrink
906+instance Arbitrary Compression where arbitrary = arbitraryCompression
907+makeArbitrary ''Bytes
930−instance Arbitrary Bytes where arbitrary = sopArbitrary; shrink = genericShrink
908+instance Arbitrary Bytes where arbitrary = arbitraryBytes
909+makeArbitrary ''AllocationPolicy
931−instance Arbitrary AllocationPolicy where arbitrary = sopArbitrary; shrink = genericShrink
910+instance Arbitrary AllocationPolicy where arbitrary = arbitraryAllocationPolicy
911+makeArbitrary ''InitialShardCount
932−instance Arbitrary InitialShardCount where arbitrary = sopArbitrary; shrink = genericShrink
912+instance Arbitrary InitialShardCount where arbitrary = arbitraryInitialShardCount
913+makeArbitrary ''FSType
933−instance Arbitrary FSType where arbitrary = sopArbitrary; shrink = genericShrink
914+instance Arbitrary FSType where arbitrary = arbitraryFSType
915+makeArbitrary ''CompoundFormat
934−instance Arbitrary CompoundFormat where arbitrary = sopArbitrary; shrink = genericShrink
916+instance Arbitrary CompoundFormat where arbitrary = arbitraryCompoundFormat
917+makeArbitrary ''FsSnapshotRepo
935−instance Arbitrary FsSnapshotRepo where arbitrary = sopArbitrary; shrink = genericShrink
918+instance Arbitrary FsSnapshotRepo where arbitrary = arbitraryFsSnapshotRepo
919+makeArbitrary ''SnapshotRepoName
936−instance Arbitrary SnapshotRepoName where arbitrary = sopArbitrary; shrink = genericShrink
920+instance Arbitrary SnapshotRepoName where arbitrary = arbitrarySnapshotRepoName
921+makeArbitrary ''TemplateQueryInline
937−instance Arbitrary TemplateQueryInline where arbitrary = sopArbitrary; shrink = genericShrink
922+instance Arbitrary TemplateQueryInline where arbitrary = arbitraryTemplateQueryInline
923+makeArbitrary ''PhraseSuggesterCollate
938−instance Arbitrary PhraseSuggesterCollate where arbitrary = sopArbitrary; shrink = genericShrink
924+instance Arbitrary PhraseSuggesterCollate where arbitrary = arbitraryPhraseSuggesterCollate
925+makeArbitrary ''PhraseSuggesterHighlighter
939−instance Arbitrary PhraseSuggesterHighlighter where arbitrary = sopArbitrary; shrink = genericShrink
926+instance Arbitrary PhraseSuggesterHighlighter where arbitrary = arbitraryPhraseSuggesterHighlighter
940−instance Arbitrary Size where arbitrary = sopArbitrary; shrink = genericShrink
928+instance Arbitrary Size where arbitrary = arbitrarySize
929+makeArbitrary ''PhraseSuggester
941−instance Arbitrary PhraseSuggester where arbitrary = sopArbitrary; shrink = genericShrink
930+instance Arbitrary PhraseSuggester where arbitrary = arbitraryPhraseSuggester
931+makeArbitrary ''SuggestType
942−instance Arbitrary SuggestType where arbitrary = sopArbitrary; shrink = genericShrink
932+instance Arbitrary SuggestType where arbitrary = arbitrarySuggestType
933+makeArbitrary ''Suggest
943−instance Arbitrary Suggest where arbitrary = sopArbitrary; shrink = genericShrink
934+instance Arbitrary Suggest where arbitrary = arbitrarySuggest
936+newtype UpdatableIndexSetting' =
945−newtype UpdatableIndexSetting' = UpdatableIndexSetting' UpdatableIndexSetting
937+ UpdatableIndexSetting' UpdatableIndexSetting
946− deriving (Show, Eq, ToJSON, FromJSON, ApproxEq, Typeable)
938+ deriving (Show, Eq, ToJSON, FromJSON, ApproxEq, Typeable)
948instance Arbitrary UpdatableIndexSetting' where
940instance Arbitrary UpdatableIndexSetting' where
949 arbitrary = do
941 arbitrary = do
950 settings <- arbitrary
942 settings <- arbitrary
951 return $ UpdatableIndexSetting' $ case settings of
943 return $ UpdatableIndexSetting' $ case settings of
944+ RoutingAllocationInclude xs ->
952− RoutingAllocationInclude xs -> RoutingAllocationInclude (dropDuplicateAttrNames xs)
945+ RoutingAllocationInclude (dropDuplicateAttrNames xs)
946+ RoutingAllocationExclude xs ->
953− RoutingAllocationExclude xs -> RoutingAllocationExclude (dropDuplicateAttrNames xs)
947+ RoutingAllocationExclude (dropDuplicateAttrNames xs)
948+ RoutingAllocationRequire xs ->
954− RoutingAllocationRequire xs -> RoutingAllocationRequire (dropDuplicateAttrNames xs)
949+ RoutingAllocationRequire (dropDuplicateAttrNames xs)
952+ dropDuplicateAttrNames =
957− dropDuplicateAttrNames = NE.fromList . L.nubBy sameAttrName . NE.toList
953+ NE.fromList . L.nubBy sameAttrName . NE.toList
958− sameAttrName a b = nodeAttrFilterName a == nodeAttrFilterName b
955+ nodeAttrFilterName a == nodeAttrFilterName b
957+-- | Due to the way nodeattrfilters get serialized here, they may come
958+-- out in a different order, but they are morally equivalent
959+instance ApproxEq UpdatableIndexSetting where
960+ RoutingAllocationInclude a =~ RoutingAllocationInclude b =
961+ NE.sort a =~ NE.sort b
962+ RoutingAllocationExclude a =~ RoutingAllocationExclude b =
963+ NE.sort a =~ NE.sort b
964+ RoutingAllocationRequire a =~ RoutingAllocationRequire b =
965+ NE.sort a =~ NE.sort b
967+ showApproxEq (RoutingAllocationInclude xs) = show (RoutingAllocationInclude (NE.sort xs))
968+ showApproxEq (RoutingAllocationExclude xs) = show (RoutingAllocationExclude (NE.sort xs))
969+ showApproxEq (RoutingAllocationRequire xs) = show (RoutingAllocationRequire (NE.sort xs))
970+ showApproxEq x = show x
960main :: IO ()
972main :: IO ()
961main = hspec $ do
973main = hspec $ do
@@ -1055,14 +1067,26 @@ main = hspec $ do
1055 let thirdDoc = BulkCreateEncoding testIndex
1067 let thirdDoc = BulkCreateEncoding testIndex
1056 testMapping (DocId "4") (toEncoding thirdTest)
1068 testMapping (DocId "4") (toEncoding thirdTest)
1057 let stream = V.fromList [firstDoc, secondDoc, thirdDoc]
1069 let stream = V.fromList [firstDoc, secondDoc, thirdDoc]
1058− _ <- bulk stream
1070+ bulkResp <- bulk stream
1071+ liftIO $ pPrint bulkResp
1059− _ <- refreshIndex testIndex
1072+ refreshResp <- refreshIndex testIndex
1073+ liftIO $ pPrint refreshResp
1060 fDoc <- getDocument testIndex testMapping (DocId "2")
1074 fDoc <- getDocument testIndex testMapping (DocId "2")
1061 sDoc <- getDocument testIndex testMapping (DocId "3")
1075 sDoc <- getDocument testIndex testMapping (DocId "3")
1062 tDoc <- getDocument testIndex testMapping (DocId "4")
1076 tDoc <- getDocument testIndex testMapping (DocId "4")
1079+ $ responseBody fDoc
1063− let maybeFirst = eitherDecode $ responseBody fDoc :: Either String (EsResult BulkTest)
1080+ :: Either String (EsResult BulkTest)
1083+ $ responseBody sDoc
1064− let maybeSecond = eitherDecode $ responseBody sDoc :: Either String (EsResult BulkTest)
1084+ :: Either String (EsResult BulkTest)
1087+ $ responseBody tDoc
1065− let maybeThird = eitherDecode $ responseBody tDoc :: Either String (EsResult BulkTest)
1088+ :: Either String (EsResult BulkTest)
1089+ liftIO $ pPrint [maybeFirst, maybeSecond, maybeThird]
1066 liftIO $ do
1090 liftIO $ do
1067 fmap getSource maybeFirst `shouldBe` Right (Just firstTest)
1091 fmap getSource maybeFirst `shouldBe` Right (Just firstTest)
1068 fmap getSource maybeSecond `shouldBe` Right (Just secondTest)
1092 fmap getSource maybeSecond `shouldBe` Right (Just secondTest)
@@ -1602,10 +1626,14 @@ main = hspec $ do
1602 liftIO $ validateStatus resp 200
1626 liftIO $ validateStatus resp 200
1603 deleteIndexAlias aname
1627 deleteIndexAlias aname
1604 getIndexAliases
1628 getIndexAliases
1605− let expected = IndexAliasSummary alias create
1629+ -- let expected = IndexAliasSummary alias create
1606 case aliases of
1630 case aliases of
1607 Right (IndexAliasesSummary summs) ->
1631 Right (IndexAliasesSummary summs) ->
1632+ L.find ( (== aname)
1608− L.find ((== aname) . indexAlias . indexAliasSummaryAlias) summs `shouldBe` Nothing
1634+ . indexAliasSummaryAlias
1609 Left e -> expectationFailure ("Expected an IndexAliasesSummary but got " <> show e)
1637 Left e -> expectationFailure ("Expected an IndexAliasesSummary but got " <> show e)
1611 describe "Index Listing" $ do
1639 describe "Index Listing" $ do
@@ -1701,7 +1729,7 @@ main = hspec $ do
1701 Left e -> liftIO $ expectationFailure ("Expected an search suggestion but got " <> show e)
1729 Left e -> liftIO $ expectationFailure ("Expected an search suggestion but got " <> show e)
1702 Right sr -> liftIO $ (suggestOptionsText . head . suggestResponseOptions . head . nsrResponses <$> suggest sr) `shouldBe` expectedText
1730 Right sr -> liftIO $ (suggestOptionsText . head . suggestResponseOptions . head . nsrResponses <$> suggest sr) `shouldBe` expectedText
1704− describe "JSON instances" $ do
1732+ describe "Exact isomorphism JSON instances" $ do
1705 propJSON (Proxy :: Proxy Version)
1733 propJSON (Proxy :: Proxy Version)
1706 propJSON (Proxy :: Proxy IndexName)
1734 propJSON (Proxy :: Proxy IndexName)
1707 propJSON (Proxy :: Proxy MappingName)
1735 propJSON (Proxy :: Proxy MappingName)
@@ -1796,26 +1824,14 @@ main = hspec $ do
1796 propJSON (Proxy :: Proxy Term)
1824 propJSON (Proxy :: Proxy Term)
1797 propJSON (Proxy :: Proxy MultiMatchQuery)
1825 propJSON (Proxy :: Proxy MultiMatchQuery)
1798 propJSON (Proxy :: Proxy IndexSettings)
1826 propJSON (Proxy :: Proxy IndexSettings)
1799− propJSON (Proxy :: Proxy UpdatableIndexSetting')
1800− propJSON (Proxy :: Proxy ReplicaBounds)
1801− propJSON (Proxy :: Proxy Bytes)
1802− propJSON (Proxy :: Proxy AllocationPolicy)
1803− propJSON (Proxy :: Proxy InitialShardCount)
1804− propJSON (Proxy :: Proxy FSType)
1805 propJSON (Proxy :: Proxy CompoundFormat)
1827 propJSON (Proxy :: Proxy CompoundFormat)
1806 propJSON (Proxy :: Proxy TemplateQueryInline)
1828 propJSON (Proxy :: Proxy TemplateQueryInline)
1807 propJSON (Proxy :: Proxy Suggest)
1829 propJSON (Proxy :: Proxy Suggest)
1808−
1830+ describe "Approximate isomorphism JSON instances" $ do
1809−-- Temporary solution for lacking of generic derivation of Arbitrary
1831+ propApproxJSON (Proxy :: Proxy UpdatableIndexSetting')
1810−-- We use generics-sop, as it's much more concise than directly using GHC.Generics
1832+ propApproxJSON (Proxy :: Proxy ReplicaCount)
1811−--
1833+ propApproxJSON (Proxy :: Proxy ReplicaBounds)
1812−-- This will be unneeded after https://github.com/nick8325/quickcheck/pull/112
1834+ propApproxJSON (Proxy :: Proxy Bytes)
1813−-- is merged and released
1835+ propApproxJSON (Proxy :: Proxy AllocationPolicy)
1814−sopArbitrary :: forall a. (Generic a, SOP.GTo a, SOP.All SOP.SListI (SOP.GCode a), SOP.All2 Arbitrary (SOP.GCode a)) => Gen a
1836+ propApproxJSON (Proxy :: Proxy InitialShardCount)
1815−sopArbitrary = fmap SOP.gto sopArbitrary'
1837+ propApproxJSON (Proxy :: Proxy FSType)
1817−sopArbitrary' :: forall xss. (SOP.All SOP.SListI xss, SOP.All2 Arbitrary xss) => Gen (SOP.SOP SOP.I xss)
1818−sopArbitrary' = SOP.hsequence =<< elements (SOP.apInjs_POP $ SOP.hcpure p arbitrary)
1820− p :: Proxy Arbitrary