git.iko.soy/typeable/bloodhound
on master help sign in
Merge pull request #133 from alistair/parent_child_test_fix
0415794Chris Allen
tests/tests.hs+21−4
@@ -177,15 +177,32 @@ data ParentMapping = ParentMapping deriving (Eq, Show)
177
177
178instance ToJSON ParentMapping where
178instance ToJSON ParentMapping where
179 toJSON ParentMapping =
179 toJSON ParentMapping =
180− object ["parent" .= Null ]
180+ object ["parent" .=
181+ object ["properties" .=
182+ object [ "user" .= object ["type" .= ("string" :: Text)]
183+ -- Serializing the date as a date is breaking other tests, mysteriously.
184+ -- , "postDate" .= object [ "type" .= ("date" :: Text)
185+ -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
186+ , "message" .= object ["type" .= ("string" :: Text)]
187+ , "age" .= object ["type" .= ("integer" :: Text)]
188+ , "location" .= object ["type" .= ("geo_point" :: Text)]
189+ ]]]
181
190
182data ChildMapping = ChildMapping deriving (Eq, Show)
191data ChildMapping = ChildMapping deriving (Eq, Show)
183
192
184instance ToJSON ChildMapping where
193instance ToJSON ChildMapping where
185 toJSON ChildMapping =
194 toJSON ChildMapping =
186 object ["child" .=
195 object ["child" .=
187− object ["_parent" .= object ["type" .= ("parent" :: Text)]]
196+ object ["_parent" .= object ["type" .= ("parent" :: Text)]
197+ , "properties" .=
198+ object [ "user" .= object ["type" .= ("string" :: Text)]
199+ -- Serializing the date as a date is breaking other tests, mysteriously.
200+ -- , "postDate" .= object [ "type" .= ("date" :: Text)
201+ -- , "format" .= ("YYYY-MM-dd`T`HH:mm:ss.SSSZZ" :: Text)]
202+ , "message" .= object ["type" .= ("string" :: Text)]
203+ , "age" .= object ["type" .= ("integer" :: Text)]
204+ , "location" .= object ["type" .= ("geo_point" :: Text)]
188− ]
205+ ]]]
189
206
190data TweetMapping = TweetMapping deriving (Eq, Show)
207data TweetMapping = TweetMapping deriving (Eq, Show)
191
208
@@ -932,8 +949,8 @@ main = hspec $ do
932
949
933 it "indexes two documents in a parent/child relationship and checks that the child exists" $ withTestEnv $ do
950 it "indexes two documents in a parent/child relationship and checks that the child exists" $ withTestEnv $ do
934 resetIndex
951 resetIndex
935− _ <- putMapping testIndex (MappingName "parent") ParentMapping
936 _ <- putMapping testIndex (MappingName "child") ChildMapping
952 _ <- putMapping testIndex (MappingName "child") ChildMapping
953+ _ <- putMapping testIndex (MappingName "parent") ParentMapping
937 _ <- indexDocument testIndex (MappingName "parent") defaultIndexDocumentSettings exampleTweet (DocId "1")
954 _ <- indexDocument testIndex (MappingName "parent") defaultIndexDocumentSettings exampleTweet (DocId "1")
938 let parent = (Just . DocumentParent . DocId) "1"
955 let parent = (Just . DocumentParent . DocId) "1"
939 ids = IndexDocumentSettings NoVersionControl parent
956 ids = IndexDocumentSettings NoVersionControl parent