diff --git a/overlord/snapstate/snapstate_update_test.go b/overlord/snapstate/snapstate_update_test.go index 4f5f9d36e6a..31c43af6c7a 100644 --- a/overlord/snapstate/snapstate_update_test.go +++ b/overlord/snapstate/snapstate_update_test.go @@ -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), @@ -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") diff --git a/overlord/snapstate/storehelpers.go b/overlord/snapstate/storehelpers.go index 4dc3d30f986..6d8eb361c60 100644 --- a/overlord/snapstate/storehelpers.go +++ b/overlord/snapstate/storehelpers.go @@ -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 } diff --git a/tests/main/refresh-amend/task.yaml b/tests/main/refresh-amend/task.yaml index 0f0f6f49504..fb1cd8072ac 100644 --- a/tests/main/refresh-amend/task.yaml +++ b/tests/main/refresh-amend/task.yaml @@ -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" @@ -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]+$"