[gnome-autoar/wip/oholy/extractor-raw-format-fix: 4/4] tests: Add test cases for raw format archives




commit 185684e8430063de0f1aee5952a7106cfae256a2
Author: Ondrej Holy <oholy redhat com>
Date:   Wed Nov 24 18:27:31 2021 +0100

    tests: Add test cases for raw format archives
    
    The raw format archives are not tested currently. Let's two test cass
    to reduce change that their support will be broken again.
    
    Relates: https://gitlab.gnome.org/GNOME/gnome-autoar/-/issues/38

 .../extract/test-raw-named/input/arextract.gz      | Bin 0 -> 47 bytes
 .../test-raw-named/reference/arextractdifferent    |   1 +
 .../extract/test-raw-unnamed/input/arextract.gz    | Bin 0 -> 28 bytes
 .../extract/test-raw-unnamed/reference/arextract   |   1 +
 tests/test-extract-unit.c                          |  89 +++++++++++++++++++++
 5 files changed, 91 insertions(+)
---
diff --git a/tests/files/extract/test-raw-named/input/arextract.gz 
b/tests/files/extract/test-raw-named/input/arextract.gz
new file mode 100644
index 0000000..bf32408
Binary files /dev/null and b/tests/files/extract/test-raw-named/input/arextract.gz differ
diff --git a/tests/files/extract/test-raw-named/reference/arextractdifferent 
b/tests/files/extract/test-raw-named/reference/arextractdifferent
new file mode 100644
index 0000000..86457e2
--- /dev/null
+++ b/tests/files/extract/test-raw-named/reference/arextractdifferent
@@ -0,0 +1 @@
+�o�c̃<
\ No newline at end of file
diff --git a/tests/files/extract/test-raw-unnamed/input/arextract.gz 
b/tests/files/extract/test-raw-unnamed/input/arextract.gz
new file mode 100644
index 0000000..9c90103
Binary files /dev/null and b/tests/files/extract/test-raw-unnamed/input/arextract.gz differ
diff --git a/tests/files/extract/test-raw-unnamed/reference/arextract 
b/tests/files/extract/test-raw-unnamed/reference/arextract
new file mode 100644
index 0000000..86457e2
--- /dev/null
+++ b/tests/files/extract/test-raw-unnamed/reference/arextract
@@ -0,0 +1 @@
+�o�c̃<
\ No newline at end of file
diff --git a/tests/test-extract-unit.c b/tests/test-extract-unit.c
index 5965f48..2662a5b 100644
--- a/tests/test-extract-unit.c
+++ b/tests/test-extract-unit.c
@@ -653,6 +653,90 @@ test_multiple_files_different_name (void)
   assert_reference_and_output_match (extract_test);
 }
 
+static void
+test_raw_named (void)
+{
+  /* arextract.gz
+   * └── arextractdifferent
+   *
+   * 0 directories, 1 file
+   *
+   *
+   * ref
+   * └── arextractdifferent
+   *
+   * 0 directories, 1 file
+   */
+
+  g_autoptr (ExtractTest) extract_test = NULL;
+  g_autoptr (ExtractTestData) data = NULL;
+  g_autoptr (GFile) archive = NULL;
+  g_autoptr (AutoarExtractor) extractor = NULL;
+
+  extract_test = extract_test_new ("test-raw-named");
+
+  if (!extract_test) {
+    g_assert_nonnull (extract_test);
+    return;
+  }
+
+  archive = g_file_get_child (extract_test->input, "arextract.gz");
+
+  extractor = autoar_extractor_new (archive, extract_test->output);
+  autoar_extractor_set_output_is_dest (extractor, TRUE);
+
+  data = extract_test_data_new_for_extract (extractor);
+
+  autoar_extractor_start (extractor, data->cancellable);
+
+  g_assert_cmpuint (data->number_of_files, ==, 1);
+  g_assert_no_error (data->error);
+  g_assert_true (data->completed_signalled);
+  assert_reference_and_output_match (extract_test);
+}
+
+static void
+test_raw_unnamed (void)
+{
+  /* arextract.gz
+   * └── arextract
+   *
+   * 0 directories, 1 file
+   *
+   *
+   * ref
+   * └── arextract
+   *
+   * 0 directories, 1 file
+   */
+
+  g_autoptr (ExtractTest) extract_test = NULL;
+  g_autoptr (ExtractTestData) data = NULL;
+  g_autoptr (GFile) archive = NULL;
+  g_autoptr (AutoarExtractor) extractor = NULL;
+
+  extract_test = extract_test_new ("test-raw-unnamed");
+
+  if (!extract_test) {
+    g_assert_nonnull (extract_test);
+    return;
+  }
+
+  archive = g_file_get_child (extract_test->input, "arextract.gz");
+
+  extractor = autoar_extractor_new (archive, extract_test->output);
+  autoar_extractor_set_output_is_dest (extractor, TRUE);
+
+  data = extract_test_data_new_for_extract (extractor);
+
+  autoar_extractor_start (extractor, data->cancellable);
+
+  g_assert_cmpuint (data->number_of_files, ==, 1);
+  g_assert_no_error (data->error);
+  g_assert_true (data->completed_signalled);
+  assert_reference_and_output_match (extract_test);
+}
+
 static void
 test_conflict_overwrite (void)
 {
@@ -1307,6 +1391,11 @@ setup_test_suite (void)
   g_test_add_func ("/autoar-extract/test-multiple-files-different-name",
                    test_multiple_files_different_name);
 
+  g_test_add_func ("/autoar-extract/test-raw-named",
+                   test_raw_named);
+  g_test_add_func ("/autoar-extract/test-raw-unnamed",
+                   test_raw_unnamed);
+
   g_test_add_func ("/autoar-extract/test-conflict-overwrite",
                    test_conflict_overwrite);
   g_test_add_func ("/autoar-extract/test-conflict-overwrite-nonempty-directory",


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