Commit 2f290b3a authored by Tomasz Miąsko's avatar Tomasz Miąsko

tests: Check that cancelling g_file_replace don't overwrite existing file

parent c5618703
......@@ -523,6 +523,11 @@ test_create_delete (gconstpointer d)
g_free (data);
}
static const gchar *original_data =
"/**\n"
" * g_file_replace_contents_async:\n"
"**/\n";
static const gchar *replace_data =
"/**\n"
" * g_file_replace_contents_async:\n"
......@@ -675,7 +680,8 @@ test_replace_cancel (void)
GFileInfo *info;
GCancellable *cancellable;
gchar *path;
gsize nwrote;
gchar *contents;
gsize nwrote, length;
guint count;
GError *error = NULL;
......@@ -688,8 +694,8 @@ test_replace_cancel (void)
file = g_file_get_child (tmpdir, "file");
g_file_replace_contents (file,
replace_data,
strlen (replace_data),
original_data,
strlen (original_data),
NULL, FALSE, 0, NULL,
NULL, &error);
g_assert_no_error (error);
......@@ -777,6 +783,17 @@ test_replace_cancel (void)
g_object_unref (cancellable);
g_object_unref (ostream);
/* Make sure that file contents wasn't actually replaced. */
g_file_load_contents (file,
NULL,
&contents,
&length,
NULL,
&error);
g_assert_no_error (error);
g_assert_cmpstr (contents, ==, original_data);
g_free (contents);
g_file_delete (file, NULL, &error);
g_assert_no_error (error);
g_object_unref (file);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment