From 84bacf1448127eb6d50681b6bb7144bd5421d9ef Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Sat, 23 Nov 2024 22:11:20 -0600 Subject: [PATCH] Add an autopkgtest for snapd-seed-glue. --- debian/changelog | 1 + debian/tests/control | 3 +++ debian/tests/snapd-seed-glue | 37 ++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 debian/tests/control create mode 100755 debian/tests/snapd-seed-glue diff --git a/debian/changelog b/debian/changelog index 0ee627c..a712b85 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ snapd-extra-utils (1.0.2ubuntu1) UNRELEASED; urgency=medium * In snapd-seed-glue, remove redundant decoding/encoding for account key. + * Add an autopkgtest for snapd-seed-glue. -- Simon Quigley Sat, 23 Nov 2024 21:05:07 -0600 diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 0000000..b3dc94f --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,3 @@ +Tests: snapd-seed-glue +Depends: snapd-seed-glue +Restrictions: needs-internet diff --git a/debian/tests/snapd-seed-glue b/debian/tests/snapd-seed-glue new file mode 100755 index 0000000..00616bd --- /dev/null +++ b/debian/tests/snapd-seed-glue @@ -0,0 +1,37 @@ +#!/bin/bash + +set -e + +# File to track command output, so we can check for successful completion +OUTPUT_FILE=$(mktemp) + +# If the command output does not contain a final confirmation of success, exit 1 +confirm_success () { + if grep -q "Cleanup and validation completed" "$OUTPUT_FILE"; then + rm -f "$OUTPUT_FILE" + else + exit 1 + fi +} + +echo "Testing snapd-seed-glue with firefox..." + +/usr/bin/snapd-seed-glue --verbose --seed firefox_test firefox > >(tee -a "$OUTPUT_FILE") 2>&1 +confirm_success + +echo "Add krita to the same seed..." + +/usr/bin/snapd-seed-glue --verbose --seed firefox_test firefox krita > >(tee -a "$OUTPUT_FILE") 2>&1 +confirm_success + +echo "Remove krita and replace it with Thunderbird..." + +/usr/bin/snapd-seed-glue --verbose --seed firefox_test firefox thunderbird > >(tee -a "$OUTPUT_FILE") 2>&1 +confirm_success + +echo "Confirm that non-existent snaps will fail..." + +/usr/bin/snapd-seed-glue --verbose --seed test_dir absolutelyridiculouslongnamethatwilldefinitelyneverexist > >(tee -a "$OUTPUT_FILE") 2>&1 || echo "Fail expected" +if ! grep -q "cannot install snap \"absolutelyridiculouslongnamethatwilldefinitelyneverexist\": snap not found" "$OUTPUT_FILE"; then + exit 1 +fi