Commits

John Lenz committed 4288b1d

Add tests for couchRev

Comments (0)

Files changed (2)

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

     mapM_ clearObject keys
 
     rev <- forM (zip keys vals1) $ \(k,o) -> couchPut k [] o
-    forM_ (zip3 rev keys vals1) $ \(r,k,o) ->
+
+    forM_ (zip3 rev keys vals1) $ \(r,k,o) -> do
         checkLoad k $ M.insert "_rev" (A.toJSON r) o
+        checkRevision k r
 
     rev2 <- forM (zip3 rev keys vals2) $ \(r,k,o) ->
         couchPut k [] $ M.insert "_rev" (A.toJSON r) o
 
-    forM_ (zip3 rev2 keys vals2) $ \(r,k,o) ->
+    forM_ (zip3 rev2 keys vals2) $ \(r,k,o) -> do
         checkLoad k $ M.insert "_rev" (A.toJSON r) o
+        checkRevision k r
 
     rev3 <- forM (zip3 rev2 keys vals3) $ \(r,k,o) ->
         couchPutRev k r [] o
 
-    forM_ (zip3 rev3 keys vals3) $ \(r,k,o) ->
+    forM_ (zip3 rev3 keys vals3) $ \(r,k,o) -> do
         checkLoad k $ M.insert "_rev" (A.toJSON r) o
+        checkRevision k r
 
 deleteTest :: CouchT IO ()
 deleteTest = do

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

     , assertObjMember
     , checkError
     , assertRecvError
+    , checkRevision
     , checkLoad
     , clearObject
     , ArbitraryObject(..)
     obj' <- couchGet n []
     lift $ assertBool "returned object does not match" $ isSubmapOf obj obj'
 
+checkRevision :: String -> Revision -> CouchT IO ()
+checkRevision n r = do
+    r' <- couchRev n
+    lift $ assertBool "returned revision does not match" $ r == r'
+
 -- | Delete the given object, useful for the start of a test
 clearObject :: String -> CouchT IO ()
 clearObject n = checkError (Just 404) go
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.