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

Re: CVS update: subversion/subversion/tests/libsvn_fs fs-test.c

From: Yoshiki Hayashi <yoshiki_at_xemacs.org>
Date: 2001-03-07 11:30:34 CET

Yoshiki Hayashi <yoshiki@xemacs.org> writes:

> cmpilato@tigris.org writes:
>
> > * tests/libsvn_fs/fs-test.c
>
> > (node_props): New test case for node properties.
>
> This function does not exist. Probably Franklin removed
> it. :-)

Oh, I forgot to attach the patch.

Index: subversion/tests/libsvn_fs/fs-test.c
===================================================================
RCS file: /cvs/subversion/subversion/tests/libsvn_fs/fs-test.c,v
retrieving revision 1.39
diff -u -r1.39 fs-test.c
--- subversion/tests/libsvn_fs/fs-test.c 2001/03/07 01:05:26 1.39
+++ subversion/tests/libsvn_fs/fs-test.c 2001/03/07 10:25:26
@@ -625,7 +625,6 @@
 revision_props (const char **msg)
 {
   svn_fs_t *fs;
- svn_fs_txn_t *txn;
   apr_hash_t *proplist;
   svn_string_t *value;
   int i;
@@ -647,9 +646,8 @@
 
   *msg = "set and get some revision properties";
 
- /* Open the fs and transaction */
+ /* Open the fs */
   SVN_ERR (create_fs_and_repos (&fs, "test-repo-rev-props"));
- SVN_ERR (svn_fs_begin_txn (&txn, fs, 0, pool));
 
   /* Set some properties on the revision. */
   for (i = 0; i < 4; i++)
@@ -738,6 +736,132 @@
       }
   }
   
+ /* Close the fs. */
+ SVN_ERR (svn_fs_close_fs (fs));
+
+ return SVN_NO_ERROR;
+}
+
+
+static svn_error_t *
+node_props (const char **msg)
+{
+ svn_fs_t *fs;
+ svn_fs_txn_t *txn;
+ svn_fs_root_t *txn_root;
+ apr_hash_t *proplist;
+ svn_string_t *value;
+ int i;
+
+ const char *initial_props[4][2] = {
+ { "color", "red" },
+ { "size", "XXL" },
+ { "favorite saturday morning cartoon", "looney tunes" },
+ { "auto", "Green 1997 Saturn SL1" }
+ };
+
+ const char *final_props[4][2] = {
+ { "color", "violet" },
+ { "flower", "violet" },
+ { "favorite saturday morning cartoon", "looney tunes" },
+ { "auto", "Red 2000 Chevrolet Blazer" }
+ };
+
+
+ *msg = "set and get some node properties";
+
+ /* Open the fs and transaction */
+ SVN_ERR (create_fs_and_repos (&fs, "test-repo-node-props"));
+ SVN_ERR (svn_fs_begin_txn (&txn, fs, 0, pool));
+ SVN_ERR (svn_fs_txn_root (&txn_root, txn, pool));
+
+ /* Set some properties on the node. */
+ for (i = 0; i < 4; i++)
+ {
+ SVN_ERR (svn_fs_change_node_prop
+ (txn_root, "/",
+ svn_string_create (initial_props[i][0], pool),
+ svn_string_create (initial_props[i][1], pool),
+ pool));
+ }
+
+ /* Change some of the above properties. */
+ SVN_ERR (svn_fs_change_node_prop
+ (txn_root, "/",
+ svn_string_create ("color", pool),
+ svn_string_create ("violet", pool),
+ pool));
+ SVN_ERR (svn_fs_change_node_prop
+ (txn_root, "/",
+ svn_string_create ("auto", pool),
+ svn_string_create ("Red 2000 Chevrolet Blazer", pool),
+ pool));
+
+ /* Remove a property altogether */
+ SVN_ERR (svn_fs_change_node_prop
+ (txn_root, "/",
+ svn_string_create ("size", pool),
+ NULL,
+ pool));
+
+ /* Copy a property's value into a new property. */
+ SVN_ERR (svn_fs_node_prop
+ (&value,
+ txn_root, "/",
+ svn_string_create ("color", pool),
+ pool));
+ SVN_ERR (svn_fs_change_node_prop
+ (txn_root, "/",
+ svn_string_create ("flower", pool),
+ value,
+ pool));
+
+ /* Obtain a list of all current properties, and make sure it matches
+ the expected values. */
+ SVN_ERR (svn_fs_node_proplist (&proplist, txn_root, "/", pool));
+ {
+ apr_hash_index_t *hi;
+ int num_props = 0;
+ svn_string_t *prop_name, *prop_value;
+
+ for (hi = apr_hash_first (proplist); hi; hi = apr_hash_next (hi))
+ {
+ const void *key;
+ apr_size_t klen;
+ void *val;
+
+ /* If there are more properties than expected, this is a Bad
+ Thing */
+ if (++num_props > 4)
+ return svn_error_createf
+ (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "more node properties were found than were expected");
+
+ /* Get next property */
+ apr_hash_this (hi, &key, &klen, &val);
+ prop_name = svn_string_ncreate (key, klen, pool);
+ prop_value = (svn_string_t *) val;
+
+ /* Loop through our expected final properties list, hoping to
+ find the right name with the right value. If the name is
+ missing, or the value is wrong, the whole test fails. */
+ for (i = 0; i < 4; i++)
+ {
+ if (! strcmp (prop_name->data, final_props[i][0]))
+ break;
+ }
+ if (i >= 4)
+ return svn_error_createf
+ (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "unable to find expected node property");
+
+ if (strcmp (prop_value->data, final_props[i][1]))
+ return svn_error_createf
+ (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "node property had an unexpected value");
+ }
+ }
+
   /* Close the transaction and fs. */
   SVN_ERR (svn_fs_close_txn (txn));
   SVN_ERR (svn_fs_close_fs (fs));
@@ -1442,6 +1566,7 @@
   create_greek_tree_transaction,
   list_directory,
   revision_props,
+ node_props,
   delete_mutables,
   abort_txn,
   /* fetch_youngest_rev, */

-- 
Yoshiki Hayashi
Received on Sat Oct 21 14:36:25 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.