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
|
summary: Check change abort
details: |
Check a change cannot be aborted when the change is not in progress
environment:
SNAP_NAME: test-snapd-tools
execute: |
echo "Abort with invalid id"
if snap abort 10000000; then
echo "abort with invalid id should fail"
exit 1
fi
echo "Abort with a valid id - error"
SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)"
subdirPath="$SNAP_MOUNT_DIR/$SNAP_NAME/current/foo"
mkdir -p "$subdirPath"
if "$TESTSTOOLS"/snaps-state install-local "$SNAP_NAME"; then
echo "install should fail when the target directory exists"
exit 1
fi
idPattern="\\d+(?= +Error.*?Install \"$SNAP_NAME\" snap)"
id=$(snap changes | grep -Pzo "$idPattern")
if snap abort "$id"; then
echo "abort with valid failed id should fail"
exit 1
fi
rm -rf "$subdirPath"
rmdir "$SNAP_MOUNT_DIR/$SNAP_NAME/current"
echo "Abort with a valid id - done"
"$TESTSTOOLS"/snaps-state install-local "$SNAP_NAME"
idPattern="\\d+(?= +Done.*?Install \"$SNAP_NAME\" snap)"
id=$(snap changes | grep -Pzo "$idPattern")
if snap abort "$id"; then
echo "abort with valid done id should fail"
exit 1
fi
|