• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang testing.AssertEchoArgs函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TestInstallSuccessMongodCentOS

func (s *MongoSuite) TestInstallSuccessMongodCentOS(c *gc.C) {
	type installs struct {
		series string
		pkg    string
	}
	test := installs{
		"centos7", "mongodb*",
	}

	testing.PatchExecutableAsEchoArgs(c, s, "yum")
	testing.PatchExecutableAsEchoArgs(c, s, "chcon")
	testing.PatchExecutableAsEchoArgs(c, s, "semanage")

	dataDir := c.MkDir()
	s.patchSeries(test.series)

	err := mongo.EnsureServer(makeEnsureServerParams(dataDir))
	c.Assert(err, jc.ErrorIsNil)

	expected := append(expectedArgs.YumBase, "epel-release")

	testing.AssertEchoArgs(c, "yum", expected...)

	testing.AssertEchoArgs(c, "chcon", expectedArgs.Chcon...)

	testing.AssertEchoArgs(c, "semanage", expectedArgs.Semanage...)
}
开发者ID:xushiwei,项目名称:juju,代码行数:27,代码来源:mongo_test.go


示例2: TestSetupRoutesAndIPTablesAddsRuleIfMissing

func (s *lxcBrokerSuite) TestSetupRoutesAndIPTablesAddsRuleIfMissing(c *gc.C) {
	// Isolate the test from the host machine. Because PatchExecutable
	// does not allow us to assert on subsequent executions of the
	// same binary, we need to replace the iptables commands with
	// separate ones. The check returns code=1 to trigger calling
	// add.
	fakeptablesRules := map[string]provisioner.IptablesRule{
		"IPTablesSNAT": {
			"nat",
			"POSTROUTING",
			"{{.HostIF}} {{.HostIP}}",
		},
	}
	s.PatchValue(provisioner.IptablesRules, fakeptablesRules)

	gitjujutesting.PatchExecutableAsEchoArgs(c, s, "iptables", 1, 0)
	gitjujutesting.PatchExecutableAsEchoArgs(c, s, "ip")

	ifaceInfo := []network.InterfaceInfo{{
		Address: network.NewAddress("0.1.2.3"),
	}}

	addr := network.NewAddress("0.1.2.1")
	err := provisioner.SetupRoutesAndIPTables("nic", addr, "bridge", ifaceInfo, false)
	c.Assert(err, jc.ErrorIsNil)

	// Now verify the expected commands - since check returns 1, add
	// will be called before ip route add.

	gitjujutesting.AssertEchoArgs(c, "iptables", "-t", "nat", "-C", "POSTROUTING", "nic", "0.1.2.1")
	gitjujutesting.AssertEchoArgs(c, "iptables", "-t", "nat", "-I", "POSTROUTING", "1", "nic", "0.1.2.1")
	gitjujutesting.AssertEchoArgs(c, "ip", "route", "add", "0.1.2.3", "dev", "bridge")
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:33,代码来源:lxc-broker_test.go


示例3: TestAddPPAInQuantal

func (s *MongoSuite) TestAddPPAInQuantal(c *gc.C) {
	testing.PatchExecutableAsEchoArgs(c, s, "apt-get")

	testing.PatchExecutableAsEchoArgs(c, s, "add-apt-repository")
	s.patchSeries("quantal")

	dataDir := c.MkDir()
	err := mongo.EnsureServer(makeEnsureServerParams(dataDir))
	c.Assert(err, jc.ErrorIsNil)

	pack := [][]string{
		{
			"install",
			"python-software-properties",
		}, {
			"install",
			"--target-release",
			"mongodb-server",
		},
	}
	noCommand := len(expectedArgs.AptGetBase) - 1
	for k := range pack {
		cmd := append(expectedArgs.AptGetBase[:noCommand], pack[k]...)
		testing.AssertEchoArgs(c, "apt-get", cmd...)
	}

	match := []string{
		"--yes",
		"\"ppa:juju/stable\"",
	}

	testing.AssertEchoArgs(c, "add-apt-repository", match...)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:33,代码来源:mongo_test.go


示例4: TestSyncImagesUtilizesSimpleStreamsSource

// Test that the call to SyncImages utilizes the defined source
func (s *LibVertSuite) TestSyncImagesUtilizesSimpleStreamsSource(c *gc.C) {

	const simpStreamsBinName = "uvt-simplestreams-libvirt"
	testing.PatchExecutableAsEchoArgs(c, s, simpStreamsBinName)

	const (
		series = "mocked-series"
		arch   = "mocked-arch"
		source = "mocked-url"
	)
	err := kvm.SyncImages(series, arch, source)
	c.Assert(err, jc.ErrorIsNil)

	expectedArgs := strings.Split(
		fmt.Sprintf(
			"sync arch=%s release=%s --source=%s",
			arch,
			series,
			source,
		),
		" ",
	)

	testing.AssertEchoArgs(c, simpStreamsBinName, expectedArgs...)
}
开发者ID:howbazaar,项目名称:juju,代码行数:26,代码来源:libvert_test.go


示例5: TestPatchExecutableNoArgs

func (s *cmdSuite) TestPatchExecutableNoArgs(c *gc.C) {
	s.EnsureArgFileRemoved(testFunc)
	testing.PatchExecutableAsEchoArgs(c, s, testFunc)
	output := runCommand(c, testFunc)
	c.Assert(output, gc.Equals, testFunc+"\n")
	testing.AssertEchoArgs(c, testFunc)
}
开发者ID:howbazaar,项目名称:testing,代码行数:7,代码来源:cmd_test.go


示例6: TestStartContainerUtilizesSimpleStream

func (s *KVMSuite) TestStartContainerUtilizesSimpleStream(c *gc.C) {

	const libvirtBinName = "uvt-simplestreams-libvirt"
	testing.PatchExecutableAsEchoArgs(c, s, libvirtBinName)

	startParams := kvm.StartParams{
		Series:           "mocked-series",
		Arch:             "mocked-arch",
		ImageDownloadUrl: "mocked-url",
	}
	mockedContainer := kvm.NewEmptyKvmContainer()
	mockedContainer.Start(startParams)

	expectedArgs := strings.Split(
		fmt.Sprintf(
			"sync arch=%s release=%s --source=%s",
			startParams.Arch,
			startParams.Series,
			startParams.ImageDownloadUrl,
		),
		" ",
	)

	testing.AssertEchoArgs(c, libvirtBinName, expectedArgs...)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:25,代码来源:kvm_test.go


示例7: TestCreateMachineUsesTemplate

func (s *KVMSuite) TestCreateMachineUsesTemplate(c *gc.C) {
	const uvtKvmBinName = "uvt-kvm"
	testing.PatchExecutableAsEchoArgs(c, s, uvtKvmBinName)

	tempDir := c.MkDir()
	params := kvm.CreateMachineParams{
		Hostname:      "foo-bar",
		NetworkBridge: "br0",
		Interfaces: []network.InterfaceInfo{
			{MACAddress: "00:16:3e:20:b0:11"},
		},
		UserDataFile: filepath.Join(tempDir, "something"),
	}

	err := kvm.CreateMachine(params)
	c.Assert(err, jc.ErrorIsNil)

	expectedArgs := []string{
		"create",
		"--log-console-output",
		"--user-data",
		filepath.Join(tempDir, "something"),
		"--template",
		filepath.Join(tempDir, "kvm-template.xml"),
		"foo-bar",
	}

	testing.AssertEchoArgs(c, uvtKvmBinName, expectedArgs...)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:29,代码来源:kvm_test.go


示例8: TestInstallMongod

func (s *MongoSuite) TestInstallMongod(c *gc.C) {
	type installs struct {
		series string
		cmd    [][]string
	}

	tests := []installs{
		{"precise", [][]string{{"--target-release", "precise-updates/cloud-tools", "mongodb-server"}}},
		{"quantal", [][]string{{"python-software-properties"}, {"--target-release", "mongodb-server"}}},
		{"raring", [][]string{{"--target-release", "mongodb-server"}}},
		{"saucy", [][]string{{"--target-release", "mongodb-server"}}},
		{"trusty", [][]string{{"juju-mongodb"}}},
		{"u-series", [][]string{{"juju-mongodb"}}},
	}

	testing.PatchExecutableAsEchoArgs(c, s, "add-apt-repository")
	testing.PatchExecutableAsEchoArgs(c, s, "apt-get")
	for _, test := range tests {
		dataDir := c.MkDir()
		namespace := "namespace" + test.series
		s.patchSeries(test.series)
		err := mongo.EnsureServer(makeEnsureServerParams(dataDir, namespace))
		c.Assert(err, jc.ErrorIsNil)

		for _, cmd := range test.cmd {
			match := append(expectedArgs.AptGetBase, cmd...)
			testing.AssertEchoArgs(c, "apt-get", match...)
		}
	}
}
开发者ID:imoapps,项目名称:juju,代码行数:30,代码来源:mongo_test.go


示例9: TestInstallMongod

func (s *MongoSuite) TestInstallMongod(c *gc.C) {
	type installs struct {
		series string
		cmd    [][]string
	}

	tests := []installs{
		{"precise", [][]string{{"--target-release", "precise-updates/cloud-tools", "mongodb-server"}}},
		{"trusty", [][]string{{"juju-mongodb3.2"}, {"juju-mongo-tools3.2"}}},
		{"wily", [][]string{{"juju-mongodb3.2"}, {"juju-mongo-tools3.2"}}},
		{"xenial", [][]string{{"juju-mongodb3.2"}, {"juju-mongo-tools3.2"}}},
	}

	testing.PatchExecutableAsEchoArgs(c, s, "add-apt-repository")
	testing.PatchExecutableAsEchoArgs(c, s, "apt-get")
	for _, test := range tests {
		c.Logf("install for series %v", test.series)
		dataDir := c.MkDir()
		s.patchSeries(test.series)
		err := mongo.EnsureServer(makeEnsureServerParams(dataDir))
		c.Assert(err, jc.ErrorIsNil)

		for _, cmd := range test.cmd {
			match := append(expectedArgs.AptGetBase, cmd...)
			testing.AssertEchoArgs(c, "apt-get", match...)
		}
	}
}
开发者ID:xushiwei,项目名称:juju,代码行数:28,代码来源:mongo_test.go


示例10: TestPatchExecutableWithArgs

func (s *cmdSuite) TestPatchExecutableWithArgs(c *gc.C) {
	s.EnsureArgFileRemoved(testFunc)
	testing.PatchExecutableAsEchoArgs(c, s, testFunc)
	output := runCommand(c, testFunc, "foo", "bar baz")
	c.Assert(output, gc.Equals, testFunc+" \"foo\" \"bar baz\"\n")
	testing.AssertEchoArgs(c, testFunc, "foo", "bar baz")
}
开发者ID:howbazaar,项目名称:testing,代码行数:7,代码来源:cmd_test.go


示例11: TestShutdownNoContainers

func (s *RebootSuite) TestShutdownNoContainers(c *gc.C) {
	w, err := reboot.NewRebootWaiter(s.st, s.acfg)
	c.Assert(err, jc.ErrorIsNil)
	expectedShutdownParams := s.shutdownCommandParams(c)

	err = w.ExecuteReboot(params.ShouldShutdown)
	c.Assert(err, jc.ErrorIsNil)
	testing.AssertEchoArgs(c, rebootBin, expectedShutdownParams...)
}
开发者ID:imoapps,项目名称:juju,代码行数:9,代码来源:reboot_windows_test.go


示例12: TestRebootNoContainers

func (s *RebootSuite) TestRebootNoContainers(c *gc.C) {
	w, err := reboot.NewRebootWaiter(s.st, s.acfg)
	c.Assert(err, jc.ErrorIsNil)
	expectedRebootParams := s.rebootCommandParams(c)

	err = w.ExecuteReboot(params.ShouldReboot)
	c.Assert(err, jc.ErrorIsNil)
	testing.AssertEchoArgs(c, rebootBin, expectedRebootParams...)
	ft.File{s.rebootScriptName, expectedRebootScript, 0755}.Check(c, s.tmpDir)
}
开发者ID:imoapps,项目名称:juju,代码行数:10,代码来源:reboot_nix_test.go


示例13: TestPatchExecutableWithArgs

func (s *cmdSuite) TestPatchExecutableWithArgs(c *gc.C) {
	s.EnsureArgFileRemoved(testFunc)
	testing.PatchExecutableAsEchoArgs(c, s, testFunc)
	output := runCommand(c, testFunc, "foo", "bar baz")
	output = strings.TrimRight(output, "\r\n")

	c.Assert(output, gc.DeepEquals, testFunc+" 'foo' 'bar baz'")

	testing.AssertEchoArgs(c, testFunc, "foo", "bar baz")
}
开发者ID:juju,项目名称:testing,代码行数:10,代码来源:cmd_test.go


示例14: TestPatchExecutableWithArgs

func (s *cmdSuite) TestPatchExecutableWithArgs(c *gc.C) {
	s.EnsureArgFileRemoved(testFunc)
	testing.PatchExecutableAsEchoArgs(c, s, testFunc)
	output := runCommand(c, testFunc, "foo", "bar baz")
	switch runtime.GOOS {
	case "windows":
		c.Assert(output, gc.Equals, testFunc+" \"foo\" \"bar baz\"\r\n")
	default:
		c.Assert(output, gc.Equals, testFunc+" \"foo\" \"bar baz\"\n")
	}
	testing.AssertEchoArgs(c, testFunc, "foo", "bar baz")
}
开发者ID:claudiu-coblis,项目名称:testing,代码行数:12,代码来源:cmd_test.go


示例15: TestAddEpelInCentOS

func (s *MongoSuite) TestAddEpelInCentOS(c *gc.C) {
	testing.PatchExecutableAsEchoArgs(c, s, "yum")

	s.patchSeries("centos7")

	testing.PatchExecutableAsEchoArgs(c, s, "chcon")
	testing.PatchExecutableAsEchoArgs(c, s, "semanage")

	dataDir := c.MkDir()
	err := mongo.EnsureServer(makeEnsureServerParams(dataDir, ""))
	c.Assert(err, jc.ErrorIsNil)

	expectedEpelRelease := append(expectedArgs.YumBase, "epel-release")
	testing.AssertEchoArgs(c, "yum", expectedEpelRelease...)

	expectedMongodbServer := append(expectedArgs.YumBase, "mongodb-server")
	testing.AssertEchoArgs(c, "yum", expectedMongodbServer...)

	testing.AssertEchoArgs(c, "chcon", expectedArgs.Chcon...)

	testing.AssertEchoArgs(c, "semanage", expectedArgs.Semanage...)
}
开发者ID:imoapps,项目名称:juju,代码行数:22,代码来源:mongo_test.go


示例16: TestEnsureAdminUser

func (s *adminSuite) TestEnsureAdminUser(c *gc.C) {
	inst := &gitjujutesting.MgoInstance{}
	err := inst.Start(coretesting.Certs)
	c.Assert(err, gc.IsNil)
	defer inst.DestroyWithLog()
	dialInfo := inst.DialInfo()

	// Mock out mongod, so the --noauth execution doesn't
	// do anything nasty. Also mock out the Signal method.
	gitjujutesting.PatchExecutableAsEchoArgs(c, s, "mongod")
	mongodDir := filepath.SplitList(os.Getenv("PATH"))[0]
	s.PatchValue(&mongo.JujuMongodPath, filepath.Join(mongodDir, "mongod"))
	s.PatchValue(mongo.ProcessSignal, func(*os.Process, os.Signal) error {
		return nil
	})

	// First call succeeds, as there are no users yet.
	added, err := s.ensureAdminUser(c, dialInfo, "whomever", "whatever")
	c.Assert(err, gc.IsNil)
	c.Assert(added, jc.IsTrue)

	// EnsureAdminUser should have stopped the mongo service,
	// started a new mongod with --noauth, and then finally
	// started the service back up.
	c.Assert(s.serviceStarts, gc.Equals, 1)
	c.Assert(s.serviceStops, gc.Equals, 1)
	_, portString, err := net.SplitHostPort(dialInfo.Addrs[0])
	c.Assert(err, gc.IsNil)
	gitjujutesting.AssertEchoArgs(c, "mongod",
		"--noauth",
		"--dbpath", "db",
		"--sslOnNormalPorts",
		"--sslPEMKeyFile", "server.pem",
		"--sslPEMKeyPassword", "ignored",
		"--bind_ip", "127.0.0.1",
		"--port", portString,
		"--noprealloc",
		"--syslog",
		"--smallfiles",
		"--journal",
	)

	// Second call succeeds, as the admin user is already there.
	added, err = s.ensureAdminUser(c, dialInfo, "whomever", "whatever")
	c.Assert(err, gc.IsNil)
	c.Assert(added, jc.IsFalse)

	// There should have been no additional start/stop.
	c.Assert(s.serviceStarts, gc.Equals, 1)
	c.Assert(s.serviceStops, gc.Equals, 1)
}
开发者ID:kapilt,项目名称:juju,代码行数:51,代码来源:admin_test.go


示例17: TestLXDInitZFS

func (s *InitialiserSuite) TestLXDInitZFS(c *gc.C) {
	// Patch df so it always returns 100GB
	df100 := func(path string) (uint64, error) {
		return 100 * 1024 * 1024 * 1024, nil
	}
	s.PatchValue(&df, df100)

	container := NewContainerInitialiser("xenial")
	err := container.Initialise()
	c.Assert(err, jc.ErrorIsNil)

	testing.AssertEchoArgs(c, "lxd", "init", "--auto", "--storage-backend",
		"zfs", "--storage-pool", "lxd", "--storage-create-loop", "90")
}
开发者ID:bac,项目名称:juju,代码行数:14,代码来源:initialisation_test.go


示例18: TestRebootWithContainers

func (s *RebootSuite) TestRebootWithContainers(c *gc.C) {
	testing.PatchExecutable(c, s, "lxc-ls", lxcLsScript)
	testing.PatchExecutable(c, s, "lxc-info", lxcInfoScript)
	expectedRebootParams := s.rebootCommandParams(c)

	s.PatchValue(reboot.Timeout, time.Duration(5*time.Second))
	w, err := reboot.NewRebootWaiter(s.st, s.acfg)
	c.Assert(err, jc.ErrorIsNil)

	err = w.ExecuteReboot(params.ShouldReboot)
	c.Assert(err, jc.ErrorIsNil)
	testing.AssertEchoArgs(c, rebootBin, expectedRebootParams...)
	ft.File{s.rebootScriptName, expectedRebootScript, 0755}.Check(c, s.tmpDir)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:14,代码来源:reboot_nix_test.go


示例19: TestSuccess

func (s *SetIPAndARPForwardingSuite) TestSuccess(c *gc.C) {
	// NOTE: Because PatchExecutableAsEchoArgs does not allow us to
	// assert on earlier invocations of the same binary (each run
	// overwrites the last args used), we only check sysctl was called
	// for the second key (arpProxySysctlKey). We do check the config
	// contains both though.
	fakeConfig := filepath.Join(c.MkDir(), "sysctl.conf")
	testing.PatchExecutableAsEchoArgs(c, s, "sysctl")
	s.PatchValue(provisioner.SysctlConfig, fakeConfig)

	err := provisioner.SetIPAndARPForwarding(true)
	c.Assert(err, jc.ErrorIsNil)
	expectConf := fmt.Sprintf(
		"%s=1\n%s=1",
		provisioner.IPForwardSysctlKey,
		provisioner.ARPProxySysctlKey,
	)
	AssertFileContains(c, fakeConfig, expectConf)
	expectKeyVal := fmt.Sprintf("%s=1", provisioner.IPForwardSysctlKey)
	testing.AssertEchoArgs(c, "sysctl", "-w", expectKeyVal)
	expectKeyVal = fmt.Sprintf("%s=1", provisioner.ARPProxySysctlKey)
	testing.AssertEchoArgs(c, "sysctl", "-w", expectKeyVal)

	err = provisioner.SetIPAndARPForwarding(false)
	c.Assert(err, jc.ErrorIsNil)
	expectConf = fmt.Sprintf(
		"%s=0\n%s=0",
		provisioner.IPForwardSysctlKey,
		provisioner.ARPProxySysctlKey,
	)
	AssertFileContains(c, fakeConfig, expectConf)
	expectKeyVal = fmt.Sprintf("%s=0", provisioner.IPForwardSysctlKey)
	testing.AssertEchoArgs(c, "sysctl", "-w", expectKeyVal)
	expectKeyVal = fmt.Sprintf("%s=0", provisioner.ARPProxySysctlKey)
	testing.AssertEchoArgs(c, "sysctl", "-w", expectKeyVal)
}
开发者ID:chrisjohnston,项目名称:juju,代码行数:36,代码来源:container_initialisation_test.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang testing.HomePath函数代码示例发布时间:2022-05-23
下一篇:
Golang schema.StringMap函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap