[libgdata] [documents] Fix the "remove all" test case so it doesn't fail on old ETags



commit 69a8ef2bffd54fac4bf68dee175293bc47b05fec
Author: Philip Withnall <philip tecnocode co uk>
Date:   Thu Aug 6 23:30:56 2009 +0100

    [documents] Fix the "remove all" test case so it doesn't fail on old ETags

 gdata/gdata-service.c   |    2 +-
 gdata/tests/documents.c |   21 ++++++++++++++++++---
 2 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/gdata/gdata-service.c b/gdata/gdata-service.c
index 1994487..a01921f 100644
--- a/gdata/gdata-service.c
+++ b/gdata/gdata-service.c
@@ -1549,7 +1549,7 @@ gdata_service_delete_entry_finish (GDataService *self, GAsyncResult *async_resul
  * @cancellable: optional #GCancellable object, or %NULL
  * @error: a #GError, or %NULL
  *
- * Deletes @entry from the server. For more information about the concept of updating entries, see the
+ * Deletes @entry from the server. For more information about the concept of deleting entries, see the
  * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/basics.html#DeletingEntry";>online documentation</ulink> for the GData
  * protocol.
  *
diff --git a/gdata/tests/documents.c b/gdata/tests/documents.c
index 2ffe834..3e72cbd 100644
--- a/gdata/tests/documents.c
+++ b/gdata/tests/documents.c
@@ -62,20 +62,35 @@ test_remove_all_documents_and_folders (GDataService *service)
 	g_assert (service != NULL);
 
 	query = gdata_documents_query_new (NULL);
-	gdata_documents_query_set_show_folders (query, TRUE);
+	gdata_documents_query_set_show_folders (query, FALSE);
 
 	feed = gdata_documents_service_query_documents (GDATA_DOCUMENTS_SERVICE (service), query, NULL, NULL, NULL, &error);
 	g_assert_no_error (error);
 	g_assert (GDATA_IS_DOCUMENTS_FEED (feed));
 
+	/* We delete the folders after all the files so we don't get ETag mismatches; deleting a folder changes the version
+	 * of all the documents inside it. Conversely, deleting an entry inside a folder changes the version of the folder. */
 	for (i = gdata_feed_get_entries (GDATA_FEED (feed)); i != NULL; i = i->next) {
 		gdata_service_delete_entry (GDATA_SERVICE (service), GDATA_ENTRY (i->data), NULL, &error);
 		g_assert_no_error (error);
+		g_clear_error (&error);
 	}
 
-	g_clear_error (&error);
+	g_object_unref (feed);
+
+	/* Now delete the folders */
+	gdata_documents_query_set_show_folders (query, TRUE);
+
+	feed = gdata_documents_service_query_documents (GDATA_DOCUMENTS_SERVICE (service), query, NULL, NULL, NULL, &error);
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_DOCUMENTS_FEED (feed));
+
+	for (i = gdata_feed_get_entries (GDATA_FEED (feed)); i != NULL; i = i->next) {
+		gdata_service_delete_entry (GDATA_SERVICE (service), GDATA_ENTRY (i->data), NULL, &error);
+		g_assert_no_error (error);
+		g_clear_error (&error);
+	}
 
-	/* TODO: check entries and feed properties */
 	g_object_unref (feed);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]