bitemyapp / bloodhound

Haskell Elasticsearch client and query DSL
bitemyapp.com
BSD 3-Clause "New" or "Revised" License
422 stars 118 forks source link

UpdatableIndexSetting' JSON isomorphism test failure #233

Open bitemyapp opened 6 years ago

bitemyapp commented 6 years ago
instance Arbitrary UpdatableIndexSetting' where
  arbitrary = do
    settings <- arbitrary
    return $ UpdatableIndexSetting' $ case settings of
      RoutingAllocationInclude xs ->
        RoutingAllocationInclude (dropDuplicateAttrNames xs)
      RoutingAllocationExclude xs ->
        RoutingAllocationExclude (dropDuplicateAttrNames xs)
      RoutingAllocationRequire xs ->
        RoutingAllocationRequire (dropDuplicateAttrNames xs)
      x -> x
    where
      dropDuplicateAttrNames =
        NE.fromList . L.nubBy sameAttrName . NE.toList
      sameAttrName a b =
        nodeAttrFilterName a == nodeAttrFilterName b
  shrink (UpdatableIndexSetting' x) = map UpdatableIndexSetting' (shrink x)

Currently failing in master. Any suggestions? @MichaelXavier

MichaelXavier commented 6 years ago

What does the failure say? Most of the time JSON isomorphisms fail due to either invariants that don't get enforced at the type level (e.g. duplicate keys) or type ambiguities, e.g. Maybe [a] where Nothing and [] get represented the same in the JSON.