当前位置: 首页>>代码示例>>Golang>>正文


Golang cli.ExecCommandErr函数代码示例

本文整理汇总了Golang中github.com/ubuntu-core/snappy/integration-tests/testutils/cli.ExecCommandErr函数的典型用法代码示例。如果您正苦于以下问题:Golang ExecCommandErr函数的具体用法?Golang ExecCommandErr怎么用?Golang ExecCommandErr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ExecCommandErr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: tearDownSnapd

func tearDownSnapd(fromBranch bool) error {
	if _, err := cli.ExecCommandErr("sudo", "systemctl", "stop",
		"snapd.service"); err != nil {
		return err
	}

	if _, err := cli.ExecCommandErr("sudo", "rm", "-rf", cfgDir); err != nil {
		return err
	}

	if fromBranch {
		if _, err := cli.ExecCommandErr("sudo", "umount", daemonBinaryPath); err != nil {
			return err
		}
	}

	if _, err := cli.ExecCommandErr("sudo", "systemctl", "daemon-reload"); err != nil {
		return err
	}

	if _, err := cli.ExecCommandErr("sudo", "systemctl", "start",
		"snapd.service"); err != nil {
		return err
	}

	return nil
}
开发者ID:dholbach,项目名称:snappy,代码行数:27,代码来源:base_test.go

示例2: TestPurgeRemovesDataForDeactivatedNotRemovedPackage

func (s *purgeSuite) TestPurgeRemovesDataForDeactivatedNotRemovedPackage(c *check.C) {
	defer common.RemoveSnap(c, data.BasicSnapName)
	_, err := cli.ExecCommandErr("sudo", "snappy", "deactivate", snap)
	c.Assert(err, check.IsNil)

	_, err = cli.ExecCommandErr("sudo", "snappy", "purge", snap)
	c.Assert(err, check.IsNil)

	_, err = os.Stat(snapDataPath)
	c.Assert(os.IsNotExist(err), check.Equals, true)
}
开发者ID:robert-ancell,项目名称:snapd,代码行数:11,代码来源:purge_test.go

示例3: TestPurgeHonoursInstalledFlagForNotRemovedPackage

func (s *purgeSuite) TestPurgeHonoursInstalledFlagForNotRemovedPackage(c *check.C) {
	defer common.RemoveSnap(c, data.BasicSnapName)

	dataFile := filepath.Join(snapDataPath, "data")
	_, err := cli.ExecCommandErr("sudo", "touch", dataFile)
	c.Assert(err, check.IsNil)

	_, err = cli.ExecCommandErr("sudo", "snappy", "purge", snap, "--installed")
	c.Assert(err, check.IsNil)

	_, err = os.Stat(dataFile)
	c.Assert(os.IsNotExist(err), check.Equals, true, check.Commentf("Error %v instead of os.IsNotExist", err))

	_, err = os.Stat(snapDataPath)
	c.Assert(err, check.IsNil)
}
开发者ID:robert-ancell,项目名称:snapd,代码行数:16,代码来源:purge_test.go

示例4: RemoveSnap

// RemoveSnap executes the required command to remove the specified snap
func RemoveSnap(c *check.C, packageName string) string {
	cli.ExecCommand(c, "sudo", "snap", "remove", packageName)
	// XXX: right now "snap list" on freshly booted is empty
	// because u-d-f installed aren't in state
	out, _ := cli.ExecCommandErr("snap", "list")
	return out
}
开发者ID:dholbach,项目名称:snappy,代码行数:8,代码来源:common.go

示例5: removeSnap

func removeSnap(c *check.C, packageName string) string {
	cli.ExecCommand(c, "sudo", "snap", "remove", packageName)
	// FIXME: should `snap remove` shold show a list afterards?
	//        like `snappy install`?
	// right now "snap list" on freshly booted is empty
	// because u-d-f installed aren't in state
	out, _ := cli.ExecCommandErr("snap", "list")
	return out
}
开发者ID:dholbach,项目名称:snappy,代码行数:9,代码来源:snap_example_test.go

示例6: TestDestroyUnexistingClassicMustPrintError

func (s *classicDimensionSuite) TestDestroyUnexistingClassicMustPrintError(c *check.C) {
	output, err := cli.ExecCommandErr("sudo", "snap", "destroy-classic")

	c.Check(err, check.NotNil,
		check.Commentf("Trying to destroy unexisting classic dimension did not exit with an error"))
	c.Assert(string(output), check.Equals,
		"error: Classic dimension is not enabled.\n",
		check.Commentf("Wrong error message"))
}
开发者ID:dholbach,项目名称:snappy,代码行数:9,代码来源:classic_dimension_test.go

示例7: TestPurgeReturnsErrorForNotRemovedPackage

func (s *purgeSuite) TestPurgeReturnsErrorForNotRemovedPackage(c *check.C) {
	defer common.RemoveSnap(c, data.BasicSnapName)

	_, err := cli.ExecCommandErr("sudo", "snappy", "purge", snap)
	c.Assert(err, check.NotNil)

	_, err = os.Stat(snapDataPath)
	c.Assert(err, check.IsNil)
}
开发者ID:robert-ancell,项目名称:snapd,代码行数:9,代码来源:purge_test.go

示例8: TestCallFailBinaryFromInstalledSnap

func (s *installAppSuite) TestCallFailBinaryFromInstalledSnap(c *check.C) {
	snapPath, err := build.LocalSnap(c, data.BasicBinariesSnapName)
	defer os.Remove(snapPath)
	c.Assert(err, check.IsNil, check.Commentf("Error building local snap: %s", err))
	common.InstallSnap(c, snapPath)
	defer common.RemoveSnap(c, data.BasicBinariesSnapName)

	_, err = cli.ExecCommandErr("basic-binaries.fail")
	c.Assert(err, check.NotNil, check.Commentf("The binary did not fail"))
}
开发者ID:General-Beck,项目名称:snappy,代码行数:10,代码来源:installApp_test.go

示例9: TestInstallUnexistingAppMustPrintError

func (s *installAppSuite) TestInstallUnexistingAppMustPrintError(c *check.C) {
	output, err := cli.ExecCommandErr("sudo", "snappy", "install", "unexisting.canonical")

	c.Check(err, check.NotNil,
		check.Commentf("Trying to install an unexisting snap did not exit with an error"))
	c.Assert(string(output), check.Equals,
		"Installing unexisting.canonical\n"+
			"unexisting.canonical failed to install: snappy package not found\n",
		check.Commentf("Wrong error message"))
}
开发者ID:alecu,项目名称:snappy,代码行数:10,代码来源:installApp_test.go

示例10: TestInstallUnexistingAppMustPrintError

func (s *installAppSuite) TestInstallUnexistingAppMustPrintError(c *check.C) {
	output, err := cli.ExecCommandErr("sudo", "snap", "install", "unexisting.canonical")

	c.Check(err, check.NotNil,
		check.Commentf("Trying to install an unexisting snap did not exit with an error"))
	c.Assert(string(output), testutil.Contains,
		"error: cannot perform the following tasks:\n"+
			"- Download snap \"unexisting.canonical\" from channel \"stable\" (snap not found)\n",
		check.Commentf("Wrong error message"))
}
开发者ID:dholbach,项目名称:snappy,代码行数:10,代码来源:installApp_test.go

示例11: determinePayload

func determinePayload(payload string) (string, error) {
	if _, err := os.Stat(payload); err == nil {
		// payload is a file, in order to make the snap file available to http we need to move it to its $SNAP_DATA path
		snapAppDataPath := filepath.Join("/var/lib/snaps", httpClientSnap, "current")
		if _, err := cli.ExecCommandErr("sudo", "cp", payload, snapAppDataPath); err != nil {
			return "", err
		}
		return "@" + filepath.Join(snapAppDataPath, filepath.Base(payload)), nil
	}
	// payload is a string
	return payload, nil
}
开发者ID:alecu,项目名称:snappy,代码行数:12,代码来源:snapd_test.go

示例12: TestReEnableClassicMustPrintError

func (s *classicDimensionSuite) TestReEnableClassicMustPrintError(c *check.C) {
	c.Skip("Skipping until LP: #1563193 is fixed")
	s.enableClassic(c)
	defer s.destroyClassic(c)
	output, err := cli.ExecCommandErr("sudo", "snap", "enable-classic")

	c.Check(err, check.NotNil,
		check.Commentf("Trying to re-enable classic dimension did not exit with an error"))
	c.Assert(string(output), check.Equals,
		"Classic dimension is already enabled.\n",
		check.Commentf("Wrong error message"))
}
开发者ID:dholbach,项目名称:snappy,代码行数:12,代码来源:classic_dimension_test.go

示例13: TestDeactivateRemovesBinary

func (s *activateSuite) TestDeactivateRemovesBinary(c *check.C) {
	cli.ExecCommand(c, "sudo", "snappy", "deactivate", activateSnapName)
	defer cli.ExecCommand(c, "sudo", "snappy", "activate", activateSnapName)
	output, err := cli.ExecCommandErr(activateBinName)

	c.Assert(err, check.NotNil, check.Commentf("Deactivated snap binary did not exit with an error"))
	c.Assert(output, check.Not(check.Equals), activateEchoOutput,
		check.Commentf("Deactivated snap binary was not removed"))

	list := cli.ExecCommand(c, "snappy", "list", "-v")

	c.Assert(list, check.Matches, deActivatedPattern)
}
开发者ID:robert-ancell,项目名称:snapd,代码行数:13,代码来源:activate_test.go

示例14: setUpSnapd

func setUpSnapd(c *check.C, fromBranch bool, extraEnv string) {
	cli.ExecCommand(c, "sudo", "systemctl", "stop",
		"snapd.service", "snapd.socket")

	if fromBranch {
		binPath, err := filepath.Abs("integration-tests/bin/snapd")
		c.Assert(err, check.IsNil)

		_, err = cli.ExecCommandErr("sudo", "mount", "-o", "bind",
			binPath, daemonBinaryPath)
		c.Assert(err, check.IsNil)
	}

	err := writeEnvConfig(extraEnv)
	c.Assert(err, check.IsNil)

	_, err = cli.ExecCommandErr("sudo", "systemctl", "daemon-reload")
	c.Assert(err, check.IsNil)

	_, err = cli.ExecCommandErr("sudo", "systemctl", "start", "snapd.service")
	c.Assert(err, check.IsNil)
}
开发者ID:dholbach,项目名称:snappy,代码行数:22,代码来源:base_test.go

示例15: TestPurgeRemovesDataFromRemovedPackage

func (s *purgeSuite) TestPurgeRemovesDataFromRemovedPackage(c *check.C) {
	common.RemoveSnap(c, data.BasicSnapName)

	versionSnapDataPath, err := getVersionSnapDataPath(snap)
	c.Assert(err, check.IsNil)

	_, err = os.Stat(versionSnapDataPath)
	c.Assert(err, check.IsNil)

	_, err = cli.ExecCommandErr("sudo", "snappy", "purge", snap)
	c.Assert(err, check.IsNil)

	_, err = os.Stat(versionSnapDataPath)
	c.Assert(os.IsNotExist(err), check.Equals, true)
}
开发者ID:robert-ancell,项目名称:snapd,代码行数:15,代码来源:purge_test.go


注:本文中的github.com/ubuntu-core/snappy/integration-tests/testutils/cli.ExecCommandErr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。