[gnome-autoar/wip/oholy/various-fixes: 11/23] tests: Fix tests for conflicts
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-autoar/wip/oholy/various-fixes: 11/23] tests: Fix tests for conflicts
- Date: Fri, 12 Mar 2021 15:42:20 +0000 (UTC)
commit e74a4fc02fdbc613903c8d8fd0c9dec18710b456
Author: Ondrej Holy <oholy redhat com>
Date: Thu Mar 4 13:35:31 2021 +0100
tests: Fix tests for conflicts
The tests for conflicts contains several bugs and also are not able to
distingues between skip and overwrite actions. Let's modify the test so
they can really verify whether the files are skipped, or overwritten.
.../test-conflict-skip-file/reference/arextract.txt | 2 +-
tests/test-extract-unit.c | 17 ++++++++++++-----
2 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/tests/files/extract/test-conflict-skip-file/reference/arextract.txt
b/tests/files/extract/test-conflict-skip-file/reference/arextract.txt
index 12466e2..fe97d17 100644
--- a/tests/files/extract/test-conflict-skip-file/reference/arextract.txt
+++ b/tests/files/extract/test-conflict-skip-file/reference/arextract.txt
@@ -1 +1 @@
-AutoarExtract
+this file should not be overwritten
diff --git a/tests/test-extract-unit.c b/tests/test-extract-unit.c
index 17a1508..c4e50b1 100644
--- a/tests/test-extract-unit.c
+++ b/tests/test-extract-unit.c
@@ -198,7 +198,7 @@ conflict_handler (AutoarExtractor *extractor,
gpointer user_data)
{
ExtractTestData *data = user_data;
- AutoarConflictAction action = AUTOAR_CONFLICT_SKIP;
+ AutoarConflictAction action = AUTOAR_CONFLICT_UNHANDLED;
gpointer value;
gboolean key_found;
@@ -393,7 +393,8 @@ scan_directory (GFile *directory,
if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY) {
enumerator = g_file_enumerate_children (file,
G_FILE_ATTRIBUTE_STANDARD_NAME","
- G_FILE_ATTRIBUTE_STANDARD_TYPE,
+ G_FILE_ATTRIBUTE_STANDARD_TYPE","
+ G_FILE_ATTRIBUTE_STANDARD_SIZE,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
NULL, NULL);
@@ -459,7 +460,9 @@ reference_file_scanned (GFile *scanned_file,
g_assert_cmpuint (g_file_info_get_file_type (scanned_file_info),
==,
g_file_info_get_file_type (corresponding_file_info));
-
+ g_assert_cmpuint (g_file_info_get_size (scanned_file_info),
+ ==,
+ g_file_info_get_size (corresponding_file_info));
g_hash_table_remove (extract_test->unmatched_files, relative_path);
}
}
@@ -730,8 +733,8 @@ test_conflict_overwrite (void)
conflict_file = g_file_get_child (extract_test->output,
"arextract.txt");
- g_file_copy (reference_file, conflict_file, G_FILE_COPY_NONE,
- NULL, NULL, NULL, NULL);
+ g_file_replace_contents (conflict_file, "this file should be overwritten", 31,
+ NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL, NULL);
archive = g_file_get_child (extract_test->input, "arextract.zip");
@@ -739,6 +742,10 @@ test_conflict_overwrite (void)
data = extract_test_data_new_for_extract (extractor);
+ g_hash_table_insert (data->conflict_files_actions,
+ g_object_ref (conflict_file),
+ GUINT_TO_POINTER (AUTOAR_CONFLICT_OVERWRITE));
+
autoar_extractor_start (extractor, data->cancellable);
g_assert_cmpuint (data->number_of_files, ==, 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]