summaryrefslogtreecommitdiff
path: root/tests/cli.sh
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-03 19:48:31 +0300
committerPaul Buetow <paul@buetow.org>2026-06-03 19:48:31 +0300
commit11da40444ce1bf74545f87a4bfe339f61b4660f0 (patch)
tree9d95ad210f9685a1fde54fc3cdf80b2ee280853d /tests/cli.sh
parentda8b0d3ba6d27c17f511da0284db8ae44e5e906b (diff)
Fix TAR_OPTS argv handling for si0
Diffstat (limited to 'tests/cli.sh')
-rwxr-xr-xtests/cli.sh81
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/cli.sh b/tests/cli.sh
index 939600e..590afa4 100755
--- a/tests/cli.sh
+++ b/tests/cli.sh
@@ -502,6 +502,81 @@ test_generate_cli_no_tarball_overrides_config() {
test::teardown
}
+test_generate_default_tar_opts_create_archive() {
+ local config_file
+ local fake_bin
+ local tar_log
+ local tarball
+ local tarball_listing
+
+ test::setup
+ fake_bin="$TEST_TMPDIR/bin"
+ config_file="$TEST_TMPDIR/photoalbum.conf"
+ tar_log="$TEST_TMPDIR/tar.log"
+
+ test::install_fake_imagemagick "$fake_bin"
+ test::install_tar_spy "$fake_bin"
+ PATH="$fake_bin:$PATH" \
+ test::generate_fixture_images "$TEST_TMPDIR/incoming"
+ test::write_album_config \
+ "$config_file" "$TEST_TMPDIR/incoming" "$TEST_TMPDIR/dist" \
+ 'Default tar opts' 40
+ printf 'TARBALL_INCLUDE=yes\n' >> "$config_file"
+
+ (
+ cd "$TEST_TMPDIR"
+ PATH="$fake_bin:$PATH" TEST_TAR_LOG="$tar_log" \
+ "$TEST_PHOTOALBUM" --generate
+ )
+
+ tarball=$(find "$TEST_TMPDIR/dist" -maxdepth 1 -name '*.tar' -print)
+ test::assert_contains "$TEST_TMPDIR/dist/incoming-" "$tarball"
+ tarball_listing=$(tar -tf "$tarball")
+ test::assert_contains 'incoming/01-landscape.jpg' "$tarball_listing"
+ test::assert_contains $'arg0=-c\narg1=-f' "$(<"$tar_log")"
+ test::teardown
+}
+
+test_generate_scalar_multi_tar_opts_create_archive() {
+ local config_file
+ local fake_bin
+ local tar_log
+ local tarball
+ local tarball_listing
+
+ test::setup
+ fake_bin="$TEST_TMPDIR/bin"
+ config_file="$TEST_TMPDIR/photoalbum.conf"
+ tar_log="$TEST_TMPDIR/tar.log"
+
+ test::install_fake_imagemagick "$fake_bin"
+ test::install_tar_spy "$fake_bin"
+ PATH="$fake_bin:$PATH" \
+ test::generate_fixture_images "$TEST_TMPDIR/incoming"
+ test::write_album_config \
+ "$config_file" "$TEST_TMPDIR/incoming" "$TEST_TMPDIR/dist" \
+ 'Scalar multi tar opts' 40
+ {
+ printf 'TARBALL_INCLUDE=yes\n'
+ printf 'TAR_OPTS=%q\n' '--sort=name --mtime=@0 -c'
+ } >> "$config_file"
+
+ (
+ cd "$TEST_TMPDIR"
+ PATH="$fake_bin:$PATH" TEST_TAR_LOG="$tar_log" \
+ "$TEST_PHOTOALBUM" --generate
+ )
+
+ tarball=$(find "$TEST_TMPDIR/dist" -maxdepth 1 -name '*.tar' -print)
+ test::assert_contains "$TEST_TMPDIR/dist/incoming-" "$tarball"
+ tarball_listing=$(tar -tf "$tarball")
+ test::assert_contains 'incoming/01-landscape.jpg' "$tarball_listing"
+ test::assert_contains \
+ $'arg0=--sort=name\narg1=--mtime=@0\narg2=-c\narg3=-f' \
+ "$(<"$tar_log")"
+ test::teardown
+}
+
test_default_output_reports_routine_progress() {
local config_file
local fake_bin
@@ -1685,6 +1760,12 @@ main() {
'--generate --no-tarball overrides config' \
test_generate_cli_no_tarball_overrides_config
test::run_case \
+ '--generate default TAR_OPTS creates archive' \
+ test_generate_default_tar_opts_create_archive
+ test::run_case \
+ '--generate scalar multi-option TAR_OPTS creates archive' \
+ test_generate_scalar_multi_tar_opts_create_archive
+ test::run_case \
'default output reports routine progress' \
test_default_output_reports_routine_progress
test::run_case \