Skip to content

Commit

Permalink
o/snapstate:, tests/main/refresh-amend do not ignore snaps in try mod…
Browse files Browse the repository at this point in the history
…e when amending (#14597)
  • Loading branch information
andrewphelpsj authored and ernestl committed Oct 12, 2024
1 parent d4bd9d7 commit d171356
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
11 changes: 11 additions & 0 deletions overlord/snapstate/snapstate_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,16 @@ func (s *snapmgrTestSuite) TestUpdateTasks(c *C) {
}

func (s *snapmgrTestSuite) TestUpdateAmendRunThrough(c *C) {
const tryMode = false
s.testUpdateAmendRunThrough(c, tryMode)
}

func (s *snapmgrTestSuite) TestUpdateAmendRunThroughTryMode(c *C) {
const tryMode = true
s.testUpdateAmendRunThrough(c, tryMode)
}

func (s *snapmgrTestSuite) testUpdateAmendRunThrough(c *C, tryMode bool) {
si := snap.SideInfo{
RealName: "some-snap",
Revision: snap.R(-42),
Expand All @@ -773,6 +783,7 @@ func (s *snapmgrTestSuite) TestUpdateAmendRunThrough(c *C) {
Current: si.Revision,
SnapType: "app",
TrackingChannel: "latest/stable",
Flags: snapstate.Flags{TryMode: tryMode},
})

chg := s.state.NewChange("refresh", "refresh a snap")
Expand Down
2 changes: 1 addition & 1 deletion overlord/snapstate/storehelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ func installActionsForAmend(st *state.State, updates map[string]StoreUpdate, opt

si := snapst.CurrentSideInfo()

if si == nil || si.SnapID != "" || snapst.TryMode {
if si == nil || si.SnapID != "" {
continue
}

Expand Down
22 changes: 20 additions & 2 deletions tests/main/refresh-amend/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@ details: |
`snap --amend` command. Verify after the refresh process the snap
has a store revision.
environment:
TRY_MODE: false
TRY_MODE/try_mode: true

execute: |
echo "When installing a local snap"
snap download --edge test-snapd-just-edge
snap install --dangerous ./test-snapd-just-edge_*.snap
if [ "${TRY_MODE}" = 'true' ]; then
unsquashfs -d ./test-snapd-just-edge ./test-snapd-just-edge_*.snap
snap try ./test-snapd-just-edge
else
snap install --dangerous ./test-snapd-just-edge_*.snap
fi
snap list |MATCH "test-snapd-just-edge.*x1"
echo "A normal refresh will not refresh it to the store rev"
Expand All @@ -23,8 +34,15 @@ execute: |
echo "snap refresh --amend without --edge should error but it did not"
exit 1
fi
echo "A refresh with --amend refreshes it to the store revision"
snap refresh --edge --amend test-snapd-just-edge
# we remove this dir, otherwise "snap info" will look into it and report
# information about the local snap directory
if [ "${TRY_MODE}" = 'true' ]; then
rm -r ./test-snapd-just-edge
fi
echo "And we have a store revision now"
snap info test-snapd-just-edge | MATCH "^snap-id:.*[a-zA-Z0-9]+$"

0 comments on commit d171356

Please sign in to comment.