[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Test case for svn_fs_abort_txn

From: Yoshiki Hayashi <yoshiki_at_xemacs.org>
Date: 2001-03-01 08:04:54 CET

Yoshiki Hayashi <yoshiki@xemacs.org> writes:

> (check_node_id): New helper function for abort_transaction.
> (abort_transaction): New function to test svn_fs_abort_txn().

Updated to follow yesterday's changes.

(abort_transaction): New function to test svn_fs_abort_txn().

Index: fs-test.c
===================================================================
RCS file: /cvs/subversion/subversion/tests/libsvn_fs/fs-test.c,v
retrieving revision 1.18
diff -u -r1.18 fs-test.c
--- fs-test.c 2001/03/01 00:06:10 1.18
+++ fs-test.c 2001/03/01 07:03:50
@@ -322,7 +322,58 @@
 #endif /* 0 */
 
 
+static svn_error_t *
+abort_transaction (const char **msg)
+{
+ svn_fs_t *fs;
+ svn_fs_txn_t *txn;
+ svn_fs_root_t *txn_root;
+ svn_error_t *err;
+ char *first_txn_id, *second_txn_id;
+ svn_fs_id_t *first_id, *second_id;
+ *msg = "begin a transaction, then abort transaction";
 
+ SVN_ERR (create_fs_and_repos (&fs, "test-repo-8")); /* helper */
+ SVN_ERR (svn_fs_begin_txn (&txn, fs, 0, pool));
+ SVN_ERR (svn_fs_txn_root (&txn_root, txn, pool));
+ SVN_ERR (svn_fs_txn_name (&first_txn_id, txn, pool));
+
+ /* Create a new file in the root directory.
+ ### Use more complex structure. */
+ SVN_ERR (svn_fs_make_file (txn_root, "my_file.txt", pool));
+ SVN_ERR (svn_fs_node_id (&first_id, txn_root, "/my_file.txt", pool));
+ SVN_ERR (svn_fs_abort_txn (txn));
+
+ err = svn_fs_open_txn (&txn, fs, first_txn_id, pool);
+ if (!err || err->apr_err != SVN_ERR_FS_NO_SUCH_TRANSACTION)
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "Failed to abort transaction");
+
+ /* Begin a new transaction. */
+ SVN_ERR (svn_fs_begin_txn (&txn, fs, 0, pool));
+ SVN_ERR (svn_fs_txn_root (&txn_root, txn, pool));
+ SVN_ERR (svn_fs_txn_name (&second_txn_id, txn, pool));
+
+ /* Transaction id must be different. */
+ if (! strcmp (first_txn_id, second_txn_id))
+ svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "Different transaction must have different ID.");
+
+ /* Previously created node revision of "beer.txt" must be gone now. */
+ {
+ /* Create "beer.txt" again. Since there were no other
+ transactions, it must have the same revision node ID. */
+ SVN_ERR (svn_fs_make_file (txn_root, "beer.txt", pool));
+ SVN_ERR (svn_fs_node_id (&second_id, txn_root, "/beer.txt", pool));
+ if (! svn_fs_id_eq (first_id, second_id))
+ svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "Failed to remove mutable file");
+ }
+
+ return SVN_NO_ERROR;
+}
+
+
 
 /* The test table. */
 
@@ -335,6 +386,7 @@
   reopen_trivial_transaction,
   create_file_transaction,
   verify_txn_list,
+ abort_transaction,
   0
 };
 

-- 
Yoshiki Hayashi
Received on Sat Oct 21 14:36:23 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.