@@ -143,8 +143,8 @@ is v = getServerVersion >>= \x -> return $ x == Just v
143143when' :: Monad m => m Bool -> m () -> m ()
144144when' b f = b >>= \x -> when x f
145145
146−(==~) :: (ApproxEq a, Show a) => a -> a -> Property
147−a ==~ b = counterexample (show a ++ " !=~ " ++ show b) (a =~ b)
146+(==~) :: (ApproxEq a) => a -> a -> Property
147+a ==~ b = counterexample (showApproxEq a ++ " !=~ " ++ showApproxEq b) (a =~ b)
148148
149149propJSON :: forall a. (Arbitrary a, ToJSON a, FromJSON a, Show a, ApproxEq a, Typeable a) => Proxy a -> Spec
150150propJSON _ = prop testName $ \(a :: a) ->
@@ -451,14 +451,18 @@ class ApproxEq a where
451451 default (=~) :: (Generic a, GApproxEq (Rep a)) => a -> a -> Bool
452452 a =~ b = gApproxEq (G.from a) (G.from b)
453453
454+ showApproxEq :: a -> String
455+ default showApproxEq :: (Show a) => a -> String
456+ showApproxEq = show
457+
454458instance ApproxEq NominalDiffTime where (=~) = (==)
455459instance ApproxEq UTCTime where (=~) = (==)
456460instance ApproxEq Text where (=~) = (==)
457461instance ApproxEq Bool where (=~) = (==)
458462instance ApproxEq Int where (=~) = (==)
459463instance ApproxEq Double where (=~) = (==)
460−instance ApproxEq a => ApproxEq (NonEmpty a)
461−instance ApproxEq a => ApproxEq (Maybe a)
464+instance (ApproxEq a, Show a) => ApproxEq (NonEmpty a)
465+instance (ApproxEq a, Show a) => ApproxEq (Maybe a)
462466instance ApproxEq GeoPoint
463467instance ApproxEq Regexp
464468instance ApproxEq RangeValue
@@ -575,12 +579,14 @@ instance ApproxEq AllocationPolicy
575579instance ApproxEq Char
576580instance ApproxEq Vers.Version where
577581 (=~) = (==)
578−instance ApproxEq a => ApproxEq [a] where
582+instance (ApproxEq a, Show a) => ApproxEq [a] where
579583 as =~ bs = and (zipWith (=~) as bs)
580−instance (ApproxEq l, ApproxEq r) => ApproxEq (Either l r) where
584+instance (ApproxEq l, Show l, ApproxEq r, Show r) => ApproxEq (Either l r) where
581585 Left a =~ Left b = a =~ b
582586 Right a =~ Right b = a =~ b
583587 _ =~ _ = False
588+ showApproxEq (Left x) = "Left " <> showApproxEq x
589+ showApproxEq (Right x) = "Right " <> showApproxEq x
584590instance ApproxEq NodeAttrFilter
585591instance ApproxEq NodeAttrName
586592instance ApproxEq BuildHash
@@ -595,6 +601,10 @@ instance ApproxEq UpdatableIndexSetting where
595601 RoutingAllocationRequire a =~ RoutingAllocationRequire b =
596602 NE.sort a =~ NE.sort b
597603 a =~ b = a == b
604+ showApproxEq (RoutingAllocationInclude xs) = show (RoutingAllocationInclude (NE.sort xs))
605+ showApproxEq (RoutingAllocationExclude xs) = show (RoutingAllocationExclude (NE.sort xs))
606+ showApproxEq (RoutingAllocationRequire xs) = show (RoutingAllocationRequire (NE.sort xs))
607+ showApproxEq x = show x
598608
599609
600610noDuplicates :: Eq a => [a] -> Bool
@@ -892,6 +902,21 @@ $(derive makeArbitrary ''CompoundFormat)
892902$(derive makeArbitrary ''FsSnapshotRepo)
893903$(derive makeArbitrary ''SnapshotRepoName)
894904
905+newtype UpdatableIndexSetting' = UpdatableIndexSetting' UpdatableIndexSetting
906+ deriving (Show, Eq, ToJSON, FromJSON, ApproxEq)
907+
908+instance Arbitrary UpdatableIndexSetting' where
909+ arbitrary = do
910+ settings <- arbitrary
911+ return $ UpdatableIndexSetting' $ case settings of
912+ RoutingAllocationInclude xs -> RoutingAllocationInclude (dropDuplicateAttrNames xs)
913+ RoutingAllocationExclude xs -> RoutingAllocationExclude (dropDuplicateAttrNames xs)
914+ RoutingAllocationRequire xs -> RoutingAllocationRequire (dropDuplicateAttrNames xs)
915+ x -> x
916+ where
917+ dropDuplicateAttrNames = NE.fromList . L.nubBy sameAttrName . NE.toList
918+ sameAttrName a b = nodeAttrFilterName a == nodeAttrFilterName b
919+
895920main :: IO ()
896921main = hspec $ do
897922
@@ -1808,7 +1833,7 @@ main = hspec $ do
18081833 propJSON (Proxy :: Proxy Term)
18091834 propJSON (Proxy :: Proxy MultiMatchQuery)
18101835 propJSON (Proxy :: Proxy IndexSettings)
1811− propJSON (Proxy :: Proxy UpdatableIndexSetting)
1836+ propJSON (Proxy :: Proxy UpdatableIndexSetting')
18121837 propJSON (Proxy :: Proxy ReplicaBounds)
18131838 propJSON (Proxy :: Proxy Bytes)
18141839 propJSON (Proxy :: Proxy AllocationPolicy)