示例#1
0
func (s *snapRefreshAppSuite) TestAppUpdate(c *check.C) {
	c.Skip("port to snapd")

	snap := "hello-world.canonical"
	storeSnap := fmt.Sprintf("%s", snap)

	// install edge version from the store (which is squshfs)
	cli.ExecCommand(c, "sudo", "snap", "install", storeSnap)
	defer cli.ExecCommand(c, "sudo", "snap", "remove", snap)

	// make a fakestore and make it available to snapd

	// use /var/tmp is not a tempfs for space reasons
	blobDir, err := ioutil.TempDir("/var/tmp", "snap-fake-store-blobs-")
	c.Assert(err, check.IsNil)
	defer cli.ExecCommand(c, "sudo", "rm", "-rf", blobDir)

	fakeStore := store.NewStore(blobDir)
	err = fakeStore.Start()
	c.Assert(err, check.IsNil)
	defer fakeStore.Stop()

	env := fmt.Sprintf(`SNAPPY_FORCE_CPI_URL=%s`, fakeStore.URL())
	cfg, _ := config.ReadConfig(config.DefaultFileName)
	tearDownSnapd(cfg.FromBranch)
	setUpSnapd(c, cfg.FromBranch, env)

	// run the fake update
	output := updates.CallFakeSnapRefresh(c, snap, updates.NoOp, fakeStore)
	c.Assert(output, check.Matches, "(?ms).*^hello-world.*fake1.*")
}
示例#2
0
// FIXME: remove once "snappy" the command is gone
func CallFakeUpdate(c *check.C, snap string, changeFunc ChangeFakeUpdateSnap) string {
	c.Log("Preparing fake and calling update.")

	// use /var/tmp is not a tempfs
	blobDir, err := ioutil.TempDir("/var/tmp", "snap-fake-store-blobs-")
	c.Assert(err, check.IsNil)
	defer cli.ExecCommand(c, "sudo", "rm", "-rf", blobDir)

	fakeStore := store.NewStore(blobDir)
	err = fakeStore.Start()
	c.Assert(err, check.IsNil)
	defer fakeStore.Stop()

	makeFakeUpdateForSnap(c, snap, blobDir, changeFunc)

	return cli.ExecCommand(c, "sudo", "TMPDIR=/var/tmp", fmt.Sprintf("SNAPPY_FORCE_CPI_URL=%s", fakeStore.URL()), "snap", "refresh", snap)
}