本文整理汇总了Golang中github.com/snapcore/snapd/overlord/snapstate.SnapState.Type方法的典型用法代码示例。如果您正苦于以下问题:Golang SnapState.Type方法的具体用法?Golang SnapState.Type怎么用?Golang SnapState.Type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/snapcore/snapd/overlord/snapstate.SnapState
的用法示例。
在下文中一共展示了SnapState.Type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestDoLinkSnapSuccess
func (s *linkSnapSuite) TestDoLinkSnapSuccess(c *C) {
s.state.Lock()
t := s.state.NewTask("link-snap", "test")
t.Set("snap-setup", &snapstate.SnapSetup{
SideInfo: &snap.SideInfo{
RealName: "foo",
Revision: snap.R(33),
},
Channel: "beta",
})
s.state.NewChange("dummy", "...").AddTask(t)
s.state.Unlock()
s.snapmgr.Ensure()
s.snapmgr.Wait()
s.state.Lock()
defer s.state.Unlock()
var snapst snapstate.SnapState
err := snapstate.Get(s.state, "foo", &snapst)
c.Assert(err, IsNil)
typ, err := snapst.Type()
c.Check(err, IsNil)
c.Check(typ, Equals, snap.TypeApp)
c.Check(snapst.Active, Equals, true)
c.Check(snapst.Sequence, HasLen, 1)
c.Check(snapst.Current, Equals, snap.R(33))
c.Check(snapst.Channel, Equals, "beta")
c.Check(t.Status(), Equals, state.DoneStatus)
c.Check(s.stateBackend.restartRequested, Equals, false)
}
示例2: TestDoLinkSnapSuccessCoreRestarts
func (s *linkSnapSuite) TestDoLinkSnapSuccessCoreRestarts(c *C) {
restore := release.MockOnClassic(true)
defer restore()
s.state.Lock()
si := &snap.SideInfo{
RealName: "core",
Revision: snap.R(33),
}
t := s.state.NewTask("link-snap", "test")
t.Set("snap-setup", &snapstate.SnapSetup{
SideInfo: si,
})
s.state.NewChange("dummy", "...").AddTask(t)
s.state.Unlock()
s.snapmgr.Ensure()
s.snapmgr.Wait()
s.state.Lock()
defer s.state.Unlock()
var snapst snapstate.SnapState
err := snapstate.Get(s.state, "core", &snapst)
c.Assert(err, IsNil)
typ, err := snapst.Type()
c.Check(err, IsNil)
c.Check(typ, Equals, snap.TypeOS)
c.Check(t.Status(), Equals, state.DoneStatus)
c.Check(s.stateBackend.restartRequested, Equals, true)
c.Check(t.Log(), HasLen, 1)
c.Check(t.Log()[0], Matches, `.*INFO Requested daemon restart\.`)
}