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

[PATCH] test case for svn_fs_revision_prop

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

Yoshiki Hayashi <yoshiki@xemacs.org> writes:

> Updated to follow yesterday's changes.
>
> (abort_transaction): New function to test svn_fs_abort_txn().

Sorry for sending patches for the same file again. This one
includes test case for svn_fs_revision_prop.

(abort_transaction): New function to test svn_fs_abort_txn.
(revision_property): New function to test
  svn_fs_revision_prop, svn_fs_revision_proplist,
  svn_fs_change_rev_prop.

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:56:35
@@ -322,7 +322,134 @@
 #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;
+}
+
+
+/* Put revision properties, fetch them and remove them. */
+static svn_error_t *
+revision_property (char const **msg)
+{
+ svn_fs_t *fs;
+ apr_hash_t *prop_table;
+ svn_string_t *prop1, *value1, *prop2, *value2, *prop3, *value3;
+ svn_string_t *prop4, *value4;
+ svn_string_t *value, *newval;
+ *msg = "Put revision properties, fetch them and remove them";
+
+ SVN_ERR (create_fs_and_repos (&fs, "test-repo-9")); /* helper */
+
+ prop1 = svn_string_create ("prop1", pool);
+ value1 = svn_string_create ("value1", pool);
+ prop2 = svn_string_create ("prop2", pool);
+ value2 = svn_string_create ("value2", pool);
+ prop3 = svn_string_create ("prop3", pool);
+ value3 = svn_string_create ("value3", pool);
+ prop4 = svn_string_create ("prop4", pool);
+ value4 = svn_string_create ("value4", pool);
+ newval = svn_string_create ("newval", pool);
+
+ /* Put new properties. */
+ SVN_ERR (svn_fs_change_rev_prop (fs, 0, prop1, value1, pool));
+ SVN_ERR (svn_fs_change_rev_prop (fs, 0, prop2, value2, pool));
+ SVN_ERR (svn_fs_change_rev_prop (fs, 0, prop3, value3, pool));
+ SVN_ERR (svn_fs_change_rev_prop (fs, 0, prop4, value4, pool));
+
+ /* Get property. */
+ SVN_ERR (svn_fs_revision_prop (&value, fs, 0, prop1, pool));
+ if (! svn_string_compare (value1, value))
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "Get different revision property");
+ /* Update it. */
+ SVN_ERR (svn_fs_change_rev_prop (fs, 0, prop1, newval, pool));
+ SVN_ERR (svn_fs_revision_prop (&value, fs, 0, prop1, pool));
+ if (! svn_string_compare (newval, value))
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "Failed to update revision property");
+
+ /* Test proplist. */
+ SVN_ERR (svn_fs_revision_proplist (&prop_table, fs, 0, pool));
+ if (apr_hash_count (prop_table) != 4)
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "Wrong number of properties");
+
+ /* Remove. */
+ SVN_ERR (svn_fs_change_rev_prop (fs, 0, prop3, 0, pool));
+ SVN_ERR (svn_fs_revision_proplist (&prop_table, fs, 0, pool));
+ if (apr_hash_count (prop_table) != 3)
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "Wrong number of properties");
+
+ SVN_ERR (svn_fs_change_rev_prop (fs, 0, prop2, 0, pool));
+ SVN_ERR (svn_fs_revision_proplist (&prop_table, fs, 0, pool));
+ if (apr_hash_count (prop_table) != 2)
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "Wrong number of properties");
+
+ SVN_ERR (svn_fs_change_rev_prop (fs, 0, prop1, 0, pool));
+ SVN_ERR (svn_fs_revision_proplist (&prop_table, fs, 0, pool));
+ if (apr_hash_count (prop_table) != 1)
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "Wrong number of properties");
+
+ SVN_ERR (svn_fs_change_rev_prop (fs, 0, prop4, 0, pool));
+ SVN_ERR (svn_fs_revision_proplist (&prop_table, fs, 0, pool));
+ if (apr_hash_count (prop_table) != 0)
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "Wrong number of properties");
+
+ return SVN_NO_ERROR;
+}
+
+
 
 /* The test table. */
 
@@ -335,6 +462,8 @@
   reopen_trivial_transaction,
   create_file_transaction,
   verify_txn_list,
+ abort_transaction,
+ revision_property,
   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.