Commits

John Lenz committed 4ba886d

Add test for couchPutRev and fix it so it works using If-Match as the header

  • Participants
  • Parent commits 0b5ff46

Comments (0)

Files changed (2)

src/Database/CouchDB/Enumerator.hs

      -> a           -- ^ The object to store.
      -> m Revision   
 couchPutRev p r q val = do 
-    v <- run_ $ couch' HT.methodPut p [("rev", TE.encodeUtf8 r)] q 
+    v <- run_ $ couch' HT.methodPut p [("If-Match", TE.encodeUtf8 r)] q 
             (\_ -> iterParser A.json) body
     either (liftIO . throw) return (valToObj v >>= objToRev)
   where 

test/Database/CouchDB/Enumerator/Test/Basic.hs

     let keys  = map (("otest"++) . show . (\(a,_,_) -> a)) objs'
     let vals1 = map (\(_,ArbitraryObject a,_) -> a) objs'
     let vals2 = map (\(_,_,ArbitraryObject a) -> a) objs'
+    let vals3 = map (\(_,_,ArbitraryObject a) -> a) objs'
 
     mapM_ clearObject keys
 
     forM_ (zip3 rev2 keys vals2) $ \(r,k,o) ->
         checkLoad k $ M.insert "_rev" (A.toJSON r) o
 
+    rev3 <- forM (zip3 rev2 keys vals3) $ \(r,k,o) ->
+        couchPutRev k r [] o
+
+    forM_ (zip3 rev3 keys vals3) $ \(r,k,o) ->
+        checkLoad k $ M.insert "_rev" (A.toJSON r) o
+
 deleteTest :: CouchT IO ()
 deleteTest = do
     (ArbitraryObject obj) <- liftM (head . drop 5) $ lift $ sample' arbitrary