本文整理汇总了Golang中github.com/snapcore/snapd/snap.R函数的典型用法代码示例。如果您正苦于以下问题:Golang R函数的具体用法?Golang R怎么用?Golang R使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了R函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestValidateRefreshesNoControl
func (s *assertMgrSuite) TestValidateRefreshesNoControl(c *C) {
s.state.Lock()
defer s.state.Unlock()
snapDeclFoo := s.snapDecl(c, "foo", nil)
snapDeclBar := s.snapDecl(c, "bar", nil)
s.stateFromDecl(snapDeclFoo, snap.R(7))
s.stateFromDecl(snapDeclBar, snap.R(3))
err := assertstate.Add(s.state, s.storeSigning.StoreAccountKey(""))
c.Assert(err, IsNil)
err = assertstate.Add(s.state, s.dev1Acct)
c.Assert(err, IsNil)
err = assertstate.Add(s.state, snapDeclFoo)
c.Assert(err, IsNil)
err = assertstate.Add(s.state, snapDeclBar)
c.Assert(err, IsNil)
fooRefresh := &snap.Info{
SideInfo: snap.SideInfo{RealName: "foo", SnapID: "foo-id", Revision: snap.R(9)},
}
validated, err := assertstate.ValidateRefreshes(s.state, []*snap.Info{fooRefresh}, 0)
c.Assert(err, IsNil)
c.Check(validated, DeepEquals, []*snap.Info{fooRefresh})
}
开发者ID:elopio,项目名称:snappy,代码行数:26,代码来源:assertmgr_test.go
示例2: TestDoDiscardSnapErrorsForActive
func (s *discardSnapSuite) TestDoDiscardSnapErrorsForActive(c *C) {
s.state.Lock()
snapstate.Set(s.state, "foo", &snapstate.SnapState{
Sequence: []*snap.SideInfo{
{RealName: "foo", Revision: snap.R(3)},
},
Current: snap.R(3),
Active: true,
SnapType: "app",
})
t := s.state.NewTask("discard-snap", "test")
t.Set("snap-setup", &snapstate.SnapSetup{
SideInfo: &snap.SideInfo{
RealName: "foo",
Revision: snap.R(3),
},
})
chg := s.state.NewChange("dummy", "...")
chg.AddTask(t)
s.state.Unlock()
s.snapmgr.Ensure()
s.snapmgr.Wait()
s.state.Lock()
defer s.state.Unlock()
c.Check(chg.Status(), Equals, state.ErrorStatus)
c.Check(chg.Err(), ErrorMatches, `(?s).*internal error: cannot discard snap "foo": still active.*`)
}
开发者ID:niemeyer,项目名称:snapd,代码行数:31,代码来源:discard_snap_test.go
示例3: TestDoDiscardSnapToEmpty
func (s *discardSnapSuite) TestDoDiscardSnapToEmpty(c *C) {
s.state.Lock()
snapstate.Set(s.state, "foo", &snapstate.SnapState{
Sequence: []*snap.SideInfo{
{RealName: "foo", Revision: snap.R(3)},
},
Current: snap.R(3),
SnapType: "app",
})
t := s.state.NewTask("discard-snap", "test")
t.Set("snap-setup", &snapstate.SnapSetup{
SideInfo: &snap.SideInfo{
RealName: "foo",
Revision: snap.R(33),
},
})
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, Equals, state.ErrNoState)
}
开发者ID:niemeyer,项目名称:snapd,代码行数:29,代码来源:discard_snap_test.go
示例4: TestCopyDataDoUndoNoUserHomes
func (s *copydataSuite) TestCopyDataDoUndoNoUserHomes(c *C) {
// this home dir path does not exist
oldSnapDataHomeGlob := dirs.SnapDataHomeGlob
defer func() { dirs.SnapDataHomeGlob = oldSnapDataHomeGlob }()
dirs.SnapDataHomeGlob = filepath.Join(s.tempdir, "no-such-home", "*", "snap")
v1 := snaptest.MockSnap(c, helloYaml1, helloContents, &snap.SideInfo{Revision: snap.R(10)})
s.populateData(c, snap.R(10))
// pretend we install a new version
v2 := snaptest.MockSnap(c, helloYaml2, helloContents, &snap.SideInfo{Revision: snap.R(20)})
// copy data
err := s.be.CopySnapData(v2, v1, &s.nullProgress)
c.Assert(err, IsNil)
v2data := filepath.Join(dirs.SnapDataDir, "hello/20")
l, err := filepath.Glob(filepath.Join(v2data, "*"))
c.Assert(err, IsNil)
c.Assert(l, HasLen, 1)
err = s.be.UndoCopySnapData(v2, v1, &s.nullProgress)
c.Assert(err, IsNil)
// now removed
_, err = os.Stat(v2data)
c.Assert(os.IsNotExist(err), Equals, true)
}
开发者ID:pedronis,项目名称:snappy,代码行数:27,代码来源:copydata_test.go
示例5: TestAliasAutoAliasConflict
func (s *snapmgrTestSuite) TestAliasAutoAliasConflict(c *C) {
s.state.Lock()
defer s.state.Unlock()
snapstate.Set(s.state, "alias-snap", &snapstate.SnapState{
Sequence: []*snap.SideInfo{
{RealName: "alias-snap", Revision: snap.R(11)},
},
Current: snap.R(11),
Active: true,
})
s.state.Set("aliases", map[string]map[string]string{
"other-snap": {"alias1": "auto"},
})
chg := s.state.NewChange("alias", "enable an alias")
ts, err := snapstate.Alias(s.state, "alias-snap", []string{"alias1"})
c.Assert(err, IsNil)
chg.AddAll(ts)
s.state.Unlock()
s.snapmgr.Ensure()
s.snapmgr.Wait()
s.state.Lock()
c.Check(chg.Status(), Equals, state.ErrorStatus)
c.Check(chg.Err(), ErrorMatches, `(?s).*cannot enable alias "alias1" for "alias-snap", already enabled for "other-snap".*`)
}
开发者ID:pedronis,项目名称:snappy,代码行数:30,代码来源:aliases_test.go
示例6: TestAliasSnapCommandSpaceConflict
func (s *snapmgrTestSuite) TestAliasSnapCommandSpaceConflict(c *C) {
s.state.Lock()
defer s.state.Unlock()
snapstate.Set(s.state, "alias-snap", &snapstate.SnapState{
Sequence: []*snap.SideInfo{
{RealName: "alias-snap", Revision: snap.R(11)},
},
Current: snap.R(11),
Active: true,
})
// the command namespace of this one will conflict
snapstate.Set(s.state, "alias1", &snapstate.SnapState{
Sequence: []*snap.SideInfo{
{RealName: "alias1", Revision: snap.R(3)},
},
Current: snap.R(3),
})
chg := s.state.NewChange("alias", "enable an alias")
ts, err := snapstate.Alias(s.state, "alias-snap", []string{"alias1.cmd1"})
c.Assert(err, IsNil)
chg.AddAll(ts)
s.state.Unlock()
s.snapmgr.Ensure()
s.snapmgr.Wait()
s.state.Lock()
c.Check(chg.Status(), Equals, state.ErrorStatus)
c.Check(chg.Err(), ErrorMatches, `(?s).*cannot enable alias "alias1.cmd1" for "alias-snap", it conflicts with the command namespace of installed snap "alias1".*`)
}
开发者ID:pedronis,项目名称:snappy,代码行数:34,代码来源:aliases_test.go
示例7: TestDoUndoSetAutoAliases
func (s *snapmgrTestSuite) TestDoUndoSetAutoAliases(c *C) {
s.state.Lock()
defer s.state.Unlock()
snapstate.AutoAliases = func(st *state.State, info *snap.Info) ([]string, error) {
c.Check(info.Name(), Equals, "alias-snap")
return []string{"alias1", "alias2", "alias4", "alias5"}, nil
}
snapstate.Set(s.state, "alias-snap", &snapstate.SnapState{
Sequence: []*snap.SideInfo{
{RealName: "alias-snap", Revision: snap.R(11)},
},
Current: snap.R(11),
Active: true,
})
s.state.Set("aliases", map[string]map[string]string{
"alias-snap": {
"alias1": "enabled",
"alias2": "auto",
"alias3": "auto",
"alias5": "disabled",
},
})
t := s.state.NewTask("set-auto-aliases", "test")
t.Set("snap-setup", &snapstate.SnapSetup{
SideInfo: &snap.SideInfo{RealName: "alias-snap"},
})
chg := s.state.NewChange("dummy", "...")
chg.AddTask(t)
terr := s.state.NewTask("error-trigger", "provoking total undo")
terr.WaitFor(t)
chg.AddTask(terr)
s.state.Unlock()
for i := 0; i < 3; i++ {
s.snapmgr.Ensure()
s.snapmgr.Wait()
}
s.state.Lock()
c.Check(t.Status(), Equals, state.UndoneStatus, Commentf("%v", chg.Err()))
var allAliases map[string]map[string]string
err := s.state.Get("aliases", &allAliases)
c.Assert(err, IsNil)
c.Check(allAliases, DeepEquals, map[string]map[string]string{
"alias-snap": {
"alias1": "enabled",
"alias2": "auto",
"alias3": "auto",
"alias5": "disabled",
},
})
}
开发者ID:pedronis,项目名称:snappy,代码行数:60,代码来源:aliases_test.go
示例8: TestAliasNoAlias
func (s *snapmgrTestSuite) TestAliasNoAlias(c *C) {
s.state.Lock()
defer s.state.Unlock()
snapstate.Set(s.state, "some-snap", &snapstate.SnapState{
Sequence: []*snap.SideInfo{
{RealName: "some-snap", Revision: snap.R(11)},
},
Current: snap.R(11),
Active: true,
})
chg := s.state.NewChange("alias", "enable an alias")
ts, err := snapstate.Alias(s.state, "some-snap", []string{"alias1"})
c.Assert(err, IsNil)
chg.AddAll(ts)
s.state.Unlock()
s.snapmgr.Ensure()
s.snapmgr.Wait()
s.state.Lock()
c.Check(chg.Status(), Equals, state.ErrorStatus)
c.Check(chg.Err(), ErrorMatches, `(?s).*cannot enable alias "alias1" for "some-snap", no such alias.*`)
}
开发者ID:pedronis,项目名称:snappy,代码行数:27,代码来源:aliases_test.go
示例9: TestYAML
func (s revisionSuite) TestYAML(c *C) {
for _, v := range []struct {
n int
s string
}{
{0, "unset"},
{10, `"10"`},
{-9, "x9"},
} {
r := snap.R(v.n)
data, err := yaml.Marshal(snap.R(v.n))
c.Assert(err, IsNil)
c.Assert(string(data), Equals, v.s+"\n")
var got snap.Revision
err = yaml.Unmarshal(data, &got)
c.Assert(err, IsNil)
c.Assert(got, Equals, r)
got = snap.Revision{}
err = json.Unmarshal([]byte(strconv.Itoa(r.N)), &got)
c.Assert(err, IsNil)
c.Assert(got, Equals, r)
}
}
开发者ID:niemeyer,项目名称:snapd,代码行数:25,代码来源:revision_test.go
示例10: TestCopyDataNoUserHomes
// ensure that even with no home dir there is no error and the
// system data gets copied
func (s *copydataSuite) TestCopyDataNoUserHomes(c *C) {
// this home dir path does not exist
oldSnapDataHomeGlob := dirs.SnapDataHomeGlob
defer func() { dirs.SnapDataHomeGlob = oldSnapDataHomeGlob }()
dirs.SnapDataHomeGlob = filepath.Join(s.tempdir, "no-such-home", "*", "snap")
v1 := snaptest.MockSnap(c, helloYaml1, helloContents, &snap.SideInfo{Revision: snap.R(10)})
err := s.be.CopySnapData(v1, nil, &s.nullProgress)
c.Assert(err, IsNil)
canaryDataFile := filepath.Join(v1.DataDir(), "canary.txt")
err = ioutil.WriteFile(canaryDataFile, []byte(""), 0644)
c.Assert(err, IsNil)
canaryDataFile = filepath.Join(v1.CommonDataDir(), "canary.common")
err = ioutil.WriteFile(canaryDataFile, []byte(""), 0644)
c.Assert(err, IsNil)
v2 := snaptest.MockSnap(c, helloYaml2, helloContents, &snap.SideInfo{Revision: snap.R(20)})
err = s.be.CopySnapData(v2, v1, &s.nullProgress)
c.Assert(err, IsNil)
_, err = os.Stat(filepath.Join(v2.DataDir(), "canary.txt"))
c.Assert(err, IsNil)
_, err = os.Stat(filepath.Join(v2.CommonDataDir(), "canary.common"))
c.Assert(err, IsNil)
// sanity atm
c.Check(v1.DataDir(), Not(Equals), v2.DataDir())
c.Check(v1.CommonDataDir(), Equals, v2.CommonDataDir())
}
开发者ID:pedronis,项目名称:snappy,代码行数:32,代码来源:copydata_test.go
示例11: 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)
}
开发者ID:niemeyer,项目名称:snapd,代码行数:34,代码来源:link_snap_test.go
示例12: TestCopyDataDoUndoABA
func (s *copydataSuite) TestCopyDataDoUndoABA(c *C) {
v1 := snaptest.MockSnap(c, helloYaml1, helloContents, &snap.SideInfo{Revision: snap.R(10)})
s.populateData(c, snap.R(10))
c.Check(s.populatedData("10"), Equals, "10\n")
// pretend we install a new version
v2 := snaptest.MockSnap(c, helloYaml2, helloContents, &snap.SideInfo{Revision: snap.R(20)})
// and write our own data to it
s.populateData(c, snap.R(20))
c.Check(s.populatedData("20"), Equals, "20\n")
// and now we pretend to refresh back to v1 (r10)
c.Check(s.be.CopySnapData(v1, v2, &s.nullProgress), IsNil)
// so v1 (r10) now has v2 (r20)'s data and we have trash
c.Check(s.populatedData("10"), Equals, "20\n")
c.Check(s.populatedData("10.old"), Equals, "10\n")
// but oh no! we have to undo it!
c.Check(s.be.UndoCopySnapData(v1, v2, &s.nullProgress), IsNil)
// so now v1 (r10) has v1 (r10)'s data and v2 (r20) has v2 (r20)'s data and we have no trash
c.Check(s.populatedData("10"), Equals, "10\n")
c.Check(s.populatedData("20"), Equals, "20\n")
c.Check(s.populatedData("10.old"), Equals, "")
}
开发者ID:pedronis,项目名称:snappy,代码行数:26,代码来源:copydata_test.go
示例13: TestCopyDataDoIdempotent
func (s *copydataSuite) TestCopyDataDoIdempotent(c *C) {
// make sure that a retry wouldn't stumble on partial work
v1 := snaptest.MockSnap(c, helloYaml1, helloContents, &snap.SideInfo{Revision: snap.R(10)})
s.populateData(c, snap.R(10))
homedir := s.populateHomeData(c, "user1", snap.R(10))
// pretend we install a new version
v2 := snaptest.MockSnap(c, helloYaml2, helloContents, &snap.SideInfo{Revision: snap.R(20)})
// copy data
err := s.be.CopySnapData(v2, v1, &s.nullProgress)
c.Assert(err, IsNil)
err = s.be.CopySnapData(v2, v1, &s.nullProgress)
c.Assert(err, IsNil)
v2data := filepath.Join(dirs.SnapDataDir, "hello/20")
l, err := filepath.Glob(filepath.Join(v2data, "*"))
c.Assert(err, IsNil)
c.Assert(l, HasLen, 1)
v2HomeData := filepath.Join(homedir, "hello/20")
l, err = filepath.Glob(filepath.Join(v2HomeData, "*"))
c.Assert(err, IsNil)
c.Assert(l, HasLen, 1)
}
开发者ID:pedronis,项目名称:snappy,代码行数:27,代码来源:copydata_test.go
示例14: TestDoUndoMountSnap
func (s *mountSnapSuite) TestDoUndoMountSnap(c *C) {
v1 := "name: core\nversion: 1.0\n"
testSnap := snaptest.MakeTestSnapWithFiles(c, v1, nil)
s.state.Lock()
defer s.state.Unlock()
si1 := &snap.SideInfo{
RealName: "core",
Revision: snap.R(1),
}
si2 := &snap.SideInfo{
RealName: "core",
Revision: snap.R(2),
}
snapstate.Set(s.state, "core", &snapstate.SnapState{
Sequence: []*snap.SideInfo{si1},
Current: si1.Revision,
SnapType: "os",
})
t := s.state.NewTask("mount-snap", "test")
t.Set("snap-setup", &snapstate.SnapSetup{
SideInfo: si2,
SnapPath: testSnap,
})
chg := s.state.NewChange("dummy", "...")
chg.AddTask(t)
terr := s.state.NewTask("error-trigger", "provoking total undo")
terr.WaitFor(t)
chg.AddTask(terr)
s.state.Unlock()
for i := 0; i < 3; i++ {
s.snapmgr.Ensure()
s.snapmgr.Wait()
}
s.state.Lock()
// ensure undo was called the right way
c.Check(s.fakeBackend.ops, DeepEquals, fakeOps{
{
op: "current",
old: "/snap/core/1",
},
{
op: "setup-snap",
name: testSnap,
revno: snap.R(2),
},
{
op: "undo-setup-snap",
name: "/snap/core/2",
stype: "os",
},
})
}
开发者ID:niemeyer,项目名称:snapd,代码行数:60,代码来源:mount_snap_test.go
示例15: TestCopyDataUndoIdempotent
func (s *copydataSuite) TestCopyDataUndoIdempotent(c *C) {
// make sure that a retry wouldn't stumble on partial work
v1 := snaptest.MockSnap(c, helloYaml1, helloContents, &snap.SideInfo{Revision: snap.R(10)})
s.populateData(c, snap.R(10))
homedir := s.populateHomeData(c, "user1", snap.R(10))
// pretend we install a new version
v2 := snaptest.MockSnap(c, helloYaml2, helloContents, &snap.SideInfo{Revision: snap.R(20)})
// copy data
err := s.be.CopySnapData(v2, v1, &s.nullProgress)
c.Assert(err, IsNil)
v2data := filepath.Join(dirs.SnapDataDir, "hello/20")
err = s.be.UndoCopySnapData(v2, v1, &s.nullProgress)
c.Assert(err, IsNil)
err = s.be.UndoCopySnapData(v2, v1, &s.nullProgress)
c.Assert(err, IsNil)
// now removed
_, err = os.Stat(v2data)
c.Assert(os.IsNotExist(err), Equals, true)
v2HomeData := filepath.Join(homedir, "hello/20")
_, err = os.Stat(v2HomeData)
c.Assert(os.IsNotExist(err), Equals, true)
}
开发者ID:pedronis,项目名称:snappy,代码行数:29,代码来源:copydata_test.go
示例16: TestUpdateBootRevisionsKernelSimple
func (bs *bootedSuite) TestUpdateBootRevisionsKernelSimple(c *C) {
st := bs.state
st.Lock()
defer st.Unlock()
bs.makeInstalledKernelOS(c, st)
bs.bootloader.BootVars["snap_kernel"] = "canonical-pc-linux_1.snap"
err := snapstate.UpdateBootRevisions(st)
c.Assert(err, IsNil)
st.Unlock()
bs.settle()
st.Lock()
c.Assert(st.Changes(), HasLen, 1)
chg := st.Changes()[0]
c.Assert(chg.Err(), IsNil)
c.Assert(chg.Kind(), Equals, "update-revisions")
c.Assert(chg.IsReady(), Equals, true)
// canonical-pc-linux "current" got reverted but core did not
var snapst snapstate.SnapState
err = snapstate.Get(st, "canonical-pc-linux", &snapst)
c.Assert(err, IsNil)
c.Assert(snapst.Current, Equals, snap.R(1))
c.Assert(snapst.Active, Equals, true)
err = snapstate.Get(st, "core", &snapst)
c.Assert(err, IsNil)
c.Assert(snapst.Current, Equals, snap.R(2))
c.Assert(snapst.Active, Equals, true)
}
开发者ID:niemeyer,项目名称:snapd,代码行数:33,代码来源:booted_test.go
示例17: TestDeviceManagerEnsureBootOkUpdateBootRevisionsHappy
func (s *deviceMgrSuite) TestDeviceManagerEnsureBootOkUpdateBootRevisionsHappy(c *C) {
release.OnClassic = false
bootloader := boottest.NewMockBootloader("mock", c.MkDir())
partition.ForceBootloader(bootloader)
defer partition.ForceBootloader(nil)
// simulate that we have a new core_2, tried to boot it but that failed
bootloader.SetBootVars(map[string]string{
"snap_mode": "",
"snap_try_core": "core_2.snap",
"snap_core": "core_1.snap",
})
s.state.Lock()
defer s.state.Unlock()
siCore1 := &snap.SideInfo{RealName: "core", Revision: snap.R(1)}
siCore2 := &snap.SideInfo{RealName: "core", Revision: snap.R(2)}
snapstate.Set(s.state, "core", &snapstate.SnapState{
SnapType: "os",
Active: true,
Sequence: []*snap.SideInfo{siCore1, siCore2},
Current: siCore2.Revision,
})
s.state.Unlock()
err := s.mgr.EnsureBootOk()
s.state.Lock()
c.Assert(err, IsNil)
c.Check(s.state.Changes(), HasLen, 1)
c.Check(s.state.Changes()[0].Kind(), Equals, "update-revisions")
}
开发者ID:pedronis,项目名称:snappy,代码行数:33,代码来源:devicemgr_test.go
示例18: TestCopyDataDoUndo
func (s *copydataSuite) TestCopyDataDoUndo(c *C) {
v1 := snaptest.MockSnap(c, helloYaml1, helloContents, &snap.SideInfo{Revision: snap.R(10)})
s.populateData(c, snap.R(10))
homedir := s.populateHomeData(c, "user1", snap.R(10))
// pretend we install a new version
v2 := snaptest.MockSnap(c, helloYaml2, helloContents, &snap.SideInfo{Revision: snap.R(20)})
// copy data
err := s.be.CopySnapData(v2, v1, &s.nullProgress)
c.Assert(err, IsNil)
v2data := filepath.Join(dirs.SnapDataDir, "hello/20")
l, err := filepath.Glob(filepath.Join(v2data, "*"))
c.Assert(err, IsNil)
c.Assert(l, HasLen, 1)
v2HomeData := filepath.Join(homedir, "hello/20")
l, err = filepath.Glob(filepath.Join(v2HomeData, "*"))
c.Assert(err, IsNil)
c.Assert(l, HasLen, 1)
err = s.be.UndoCopySnapData(v2, v1, &s.nullProgress)
c.Assert(err, IsNil)
// now removed
_, err = os.Stat(v2data)
c.Assert(os.IsNotExist(err), Equals, true)
_, err = os.Stat(v2HomeData)
c.Assert(os.IsNotExist(err), Equals, true)
}
开发者ID:pedronis,项目名称:snappy,代码行数:29,代码来源:copydata_test.go
示例19: TestValidateRefreshesMissingValidation
func (s *assertMgrSuite) TestValidateRefreshesMissingValidation(c *C) {
s.state.Lock()
defer s.state.Unlock()
snapDeclFoo := s.snapDecl(c, "foo", nil)
snapDeclBar := s.snapDecl(c, "bar", []interface{}{"foo-id"})
s.stateFromDecl(snapDeclFoo, snap.R(7))
s.stateFromDecl(snapDeclBar, snap.R(3))
err := assertstate.Add(s.state, s.storeSigning.StoreAccountKey(""))
c.Assert(err, IsNil)
err = assertstate.Add(s.state, s.dev1Acct)
c.Assert(err, IsNil)
err = assertstate.Add(s.state, snapDeclFoo)
c.Assert(err, IsNil)
err = assertstate.Add(s.state, snapDeclBar)
c.Assert(err, IsNil)
fooRefresh := &snap.Info{
SideInfo: snap.SideInfo{RealName: "foo", SnapID: "foo-id", Revision: snap.R(9)},
}
validated, err := assertstate.ValidateRefreshes(s.state, []*snap.Info{fooRefresh}, 0)
c.Assert(err, ErrorMatches, `cannot refresh "foo" to revision 9: no validation by "bar"`)
c.Check(validated, HasLen, 0)
}
开发者ID:elopio,项目名称:snappy,代码行数:26,代码来源:assertmgr_test.go
示例20: TestDoUndoSetupAliases
func (s *snapmgrTestSuite) TestDoUndoSetupAliases(c *C) {
s.state.Lock()
defer s.state.Unlock()
snapstate.Set(s.state, "alias-snap", &snapstate.SnapState{
Sequence: []*snap.SideInfo{
{RealName: "alias-snap", Revision: snap.R(11)},
},
Current: snap.R(11),
Active: true,
})
s.state.Set("aliases", map[string]map[string]string{
"alias-snap": {
"alias1": "enabled",
},
})
t := s.state.NewTask("setup-aliases", "test")
t.Set("snap-setup", &snapstate.SnapSetup{
SideInfo: &snap.SideInfo{RealName: "alias-snap"},
})
chg := s.state.NewChange("dummy", "...")
chg.AddTask(t)
terr := s.state.NewTask("error-trigger", "provoking total undo")
terr.WaitFor(t)
chg.AddTask(terr)
s.state.Unlock()
for i := 0; i < 3; i++ {
s.snapmgr.Ensure()
s.snapmgr.Wait()
}
s.state.Lock()
c.Check(t.Status(), Equals, state.UndoneStatus)
expected := fakeOps{
{
op: "update-aliases",
aliases: []*backend.Alias{{"alias1", "alias-snap.cmd1"}},
},
{
op: "matching-aliases",
aliases: []*backend.Alias{{"alias1", "alias-snap.cmd1"}},
},
{
op: "update-aliases",
rmAliases: []*backend.Alias{{"alias1", "alias-snap.cmd1"}},
},
}
// start with an easier-to-read error if this fails:
c.Assert(s.fakeBackend.ops.Ops(), DeepEquals, expected.Ops())
c.Assert(s.fakeBackend.ops, DeepEquals, expected)
}
开发者ID:mvo5,项目名称:snappy,代码行数:56,代码来源:aliases_test.go
注:本文中的github.com/snapcore/snapd/snap.R函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论