@@ -180,6 +180,21 @@ exampleTweet = Tweet { user = "bitemyapp"
180 , age = 10000
180 , age = 10000
181 , location = Location 40.12 (-71.34) }
181 , location = Location 40.12 (-71.34) }
187+newUser = "someotherapp"
191+ object [ "age" .= newAge
195+patchedTweet :: Tweet
196+patchedTweet = exampleTweet{age = newAge, user = newUser}
183otherTweet :: Tweet
198otherTweet :: Tweet
184otherTweet = Tweet { user = "notmyapp"
199otherTweet = Tweet { user = "notmyapp"
185 , postDate = UTCTime
200 , postDate = UTCTime
@@ -207,6 +222,12 @@ insertData' ids = do
207 _ <- refreshIndex testIndex
222 _ <- refreshIndex testIndex
225+updateData :: BH IO Reply
227+ r <- updateDocument testIndex testMapping defaultIndexDocumentSettings tweetPatch (DocId "1")
228+ _ <- refreshIndex testIndex
210insertOther :: BH IO ()
231insertOther :: BH IO ()
211insertOther = do
232insertOther = do
212 _ <- indexDocument testIndex testMapping defaultIndexDocumentSettings otherTweet (DocId "2")
233 _ <- indexDocument testIndex testMapping defaultIndexDocumentSettings otherTweet (DocId "2")
@@ -761,12 +782,13 @@ main = hspec $ do
761 liftIO (errorResp `shouldBe` Right (EsError 404 "IndexMissingException[[bogus] missing]"))
782 liftIO (errorResp `shouldBe` Right (EsError 404 "IndexMissingException[[bogus] missing]"))
763 describe "document API" $ do
784 describe "document API" $ do
764− it "indexes, gets, and then deletes the generated document" $ withTestEnv $ do
785+ it "indexes, updates, gets, and then deletes the generated document" $ withTestEnv $ do
765 _ <- insertData
786 _ <- insertData
766 docInserted <- getDocument testIndex testMapping (DocId "1")
788 docInserted <- getDocument testIndex testMapping (DocId "1")
767 let newTweet = eitherDecode
789 let newTweet = eitherDecode
768 (responseBody docInserted) :: Either String (EsResult Tweet)
790 (responseBody docInserted) :: Either String (EsResult Tweet)
769− liftIO $ (fmap getSource newTweet `shouldBe` Right (Just exampleTweet))
791+ liftIO $ (fmap getSource newTweet `shouldBe` Right (Just patchedTweet))
771 it "indexes, gets, and then deletes the generated document with a DocId containing a space" $ withTestEnv $ do
793 it "indexes, gets, and then deletes the generated document with a DocId containing a space" $ withTestEnv $ do
772 _ <- insertWithSpaceInId
794 _ <- insertWithSpaceInId