1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
summary: Check snap remove operations.
details: |
Removing a snap is somewhat non-trivial: services need to be stopped, all
the revisions need to be unmounted, a snapshot of data is taken for
preservation, the snap file itself is removed. For snap packages that are
bases there cannot be any snap applications that rely on the base to be
present.
The test checks a small subset of that set, namely that removal affects all
revisions and that a base snap is not removable for as long as there are
other snaps referencing it.
execute: |
snap_revisions(){
local snap_name=$1
SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)"
echo -n "$(find "$SNAP_MOUNT_DIR/$snap_name/" -maxdepth 1 -type d -name "x*" | wc -l)"
}
echo "Given two revisions of a snap have been installed"
snap pack "$TESTSLIB"/snaps/basic
snap install --dangerous basic_1.0_all.snap
snap install --dangerous basic_1.0_all.snap
echo "Then the two revisions are available on disk"
[ "$(snap_revisions basic)" = "2" ]
echo "When the snap is removed"
snap remove basic
echo "Then the two revisions are removed from disk"
[ "$(snap_revisions basic)" = "0" ]
echo "When the snap is removed again, snap exits with status 0"
snap remove basic 2> stderr.out
MATCH 'snap "basic" is not installed' < stderr.out
echo "Install a snap that uses a base"
# test-snapd-base-bare-static uses test-snapd-base-bare
snap install --edge test-snapd-requires-base-bare
snap list | MATCH test-snapd-base-bare
if snap remove test-snapd-base-bare; then
echo "test-snapd-base-bare should not be removable because test-snapd-requires-base-bare needs it"
exit 1
fi
snap remove test-snapd-requires-base-bare
snap remove test-snapd-base-bare
|