func (s *snapmgrTestSuite) TestInstallConflict(c *C) { s.state.Lock() defer s.state.Unlock() _, err := snapstate.Install(s.state, "some-snap", "some-channel", 0, 0) c.Assert(err, IsNil) _, err = snapstate.Install(s.state, "some-snap", "some-channel", 0, 0) c.Assert(err, ErrorMatches, `snap "some-snap" has changes in progress`) }
func (s *snapmgrTestSuite) TestInstallTasks(c *C) { s.state.Lock() defer s.state.Unlock() ts, err := snapstate.Install(s.state, "some-snap", "some-channel", 0, 0) c.Assert(err, IsNil) verifyInstallUpdateTasks(c, false, ts, s.state) }
func (s *snapmgrTestSuite) TestInstallPathConflict(c *C) { s.state.Lock() defer s.state.Unlock() _, err := snapstate.Install(s.state, "some-snap", "some-channel", 0, 0) c.Assert(err, IsNil) mockSnap := makeTestSnap(c, "name: some-snap\nversion: 1.0") _, err = snapstate.InstallPath(s.state, mockSnap, "", 0) c.Assert(err, ErrorMatches, `snap "some-snap" has changes in progress`) }
func (s *snapmgrTestSuite) TestDoInstallChannelDefault(c *C) { s.state.Lock() defer s.state.Unlock() ts, err := snapstate.Install(s.state, "some-snap", "", 0, 0) c.Assert(err, IsNil) var ss snapstate.SnapSetup err = ts.Tasks()[0].Get("snap-setup", &ss) c.Assert(err, IsNil) c.Check(ss.Channel, Equals, "stable") }
func (s *snapmgrTestSuite) TestInstallIntegration(c *C) { s.state.Lock() defer s.state.Unlock() chg := s.state.NewChange("install", "install a snap") ts, err := snapstate.Install(s.state, "some-snap", "some-channel", s.user.ID, 0) c.Assert(err, IsNil) chg.AddAll(ts) s.state.Unlock() defer s.snapmgr.Stop() s.settle() s.state.Lock() // ensure all our tasks ran c.Assert(s.fakeBackend.ops, DeepEquals, []fakeOp{ fakeOp{ op: "download", macaroon: s.user.Macaroon, name: "some-snap", channel: "some-channel", }, fakeOp{ op: "check-snap", name: "downloaded-snap-path", old: "<no-current>", }, fakeOp{ op: "setup-snap", name: "downloaded-snap-path", revno: 11, }, fakeOp{ op: "copy-data", name: "/snap/some-snap/11", old: "<no-old>", }, fakeOp{ op: "candidate", sinfo: snap.SideInfo{ OfficialName: "some-snap", Channel: "some-channel", SnapID: "snapIDsnapidsnapidsnapidsnapidsn", Revision: 11, }, }, fakeOp{ op: "link-snap", name: "/snap/some-snap/11", }, }) // check progress task := ts.Tasks()[0] cur, total := task.Progress() c.Assert(cur, Equals, s.fakeBackend.fakeCurrentProgress) c.Assert(total, Equals, s.fakeBackend.fakeTotalProgress) // verify snap-setup in the task state var ss snapstate.SnapSetup err = task.Get("snap-setup", &ss) c.Assert(err, IsNil) c.Assert(ss, DeepEquals, snapstate.SnapSetup{ Name: "some-snap", Revision: 11, Channel: "some-channel", UserID: s.user.ID, SnapPath: "downloaded-snap-path", }) // verify snaps in the system state var snaps map[string]*snapstate.SnapState err = s.state.Get("snaps", &snaps) c.Assert(err, IsNil) snapst := snaps["some-snap"] c.Assert(snapst.Active, Equals, true) c.Assert(snapst.Channel, Equals, "some-channel") c.Assert(snapst.Candidate, IsNil) c.Assert(snapst.Sequence[0], DeepEquals, &snap.SideInfo{ OfficialName: "some-snap", Channel: "some-channel", SnapID: "snapIDsnapidsnapidsnapidsnapidsn", Revision: 11, }) }