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


Golang Namespace.ExecuteReturns方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry-incubator/ducati-daemon/fakes.Namespace.ExecuteReturns方法的典型用法代码示例。如果您正苦于以下问题:Golang Namespace.ExecuteReturns方法的具体用法?Golang Namespace.ExecuteReturns怎么用?Golang Namespace.ExecuteReturns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry-incubator/ducati-daemon/fakes.Namespace的用法示例。


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

示例1:

		Expect(err).NotTo(HaveOccurred())

		Expect(namespace.ExecuteCallCount()).To(Equal(1))
	})

	It("executes the command with the correct context", func() {
		err := inNamespace.Execute(context)
		Expect(err).NotTo(HaveOccurred())

		Expect(command.ExecuteCallCount()).To(Equal(1))
		Expect(command.ExecuteArgsForCall(0)).To(Equal(context))
	})

	Context("when namespace execute fails", func() {
		BeforeEach(func() {
			namespace.ExecuteReturns(errors.New("go away"))
		})

		It("wraps and propagates the error", func() {
			err := inNamespace.Execute(context)
			Expect(err).To(MatchError("execute in namespace: go away"))
		})
	})

	Context("when the target command fails", func() {
		BeforeEach(func() {
			command.ExecuteReturns(errors.New("i died"))
		})

		It("wraps and propagates the error", func() {
			err := inNamespace.Execute(context)
开发者ID:cloudfoundry-incubator,项目名称:ducati-daemon,代码行数:31,代码来源:in_namespace_test.go

示例2:

			Expect(ns.ExecuteCallCount()).To(Equal(2))
			Expect(netlinker.SetNeighArgsForCall(1)).To(Equal(&netlink.Neigh{
				LinkIndex:    9876,
				HardwareAddr: neigh.HardwareAddr,
				Family:       syscall.AF_BRIDGE,
				State:        netlink.NUD_REACHABLE,
				Type:         0,
				Flags:        netlink.NTF_SELF,
				IP:           neighbor.VTEP,
			}))
		})

		Context("when executing in namespace fails", func() {
			BeforeEach(func() {
				ns.ExecuteReturns(errors.New("peppers"))
			})

			It("returns the error", func() {
				inserter.HandleResolvedNeighbors(ready, ns, "some-vxlan-name", resolved)
				Eventually(ready).Should(Receive(MatchError("namespace execute failed: peppers")))
			})
		})

		Context("when setting a neighbor entry fails", func() {
			BeforeEach(func() {
				netlinker.SetNeighStub = func(n *netlink.Neigh) error {
					if netlinker.SetNeighCallCount() == 1 {
						return errors.New("go huskies")
					}
					return nil
开发者ID:cloudfoundry-incubator,项目名称:ducati-daemon,代码行数:30,代码来源:arp_inserter_test.go

示例3:

		written, err := nsWriter.Write([]byte{})
		Expect(err).NotTo(HaveOccurred())
		Expect(written).To(Equal(100))
	})

	It("logs the operation", func() {
		nsWriter.Write([]byte{})

		Expect(logger).To(gbytes.Say("write.write-called.*namespace.*some-inode"))
		Expect(logger).To(gbytes.Say("write.write-complete.*namespace.*some-inode"))
	})

	Context("when setting the namespae fails", func() {
		BeforeEach(func() {
			ns.ExecuteReturns(errors.New("peanuts"))
		})

		It("returns a meaningful error", func() {
			_, err := nsWriter.Write([]byte{})
			Expect(err).To(MatchError("namespace execute: peanuts"))
		})

		It("logs the error", func() {
			nsWriter.Write([]byte{})

			Expect(logger).To(gbytes.Say("write.namespace-execute-failed.*peanuts"))
		})
	})

	Context("when the wrapped writer fails", func() {
开发者ID:cloudfoundry-incubator,项目名称:ducati-daemon,代码行数:30,代码来源:namespace_writer_test.go

示例4:

				return err
			}

			err := sb.Setup()
			Expect(err).NotTo(HaveOccurred())

			Expect(sbNamespace.ExecuteCallCount()).To(Equal(1))

			Expect(linkFactory.SetUpCallCount()).To(Equal(1))
			linkName := linkFactory.SetUpArgsForCall(0)
			Expect(linkName).To(Equal("lo"))
		})

		Context("when namespace execution fails", func() {
			BeforeEach(func() {
				sbNamespace.ExecuteReturns(errors.New("boysenberry"))
			})

			It("returns a meaningful error", func() {
				err := sb.Setup()
				Expect(err).To(MatchError("setup failed: boysenberry"))
			})
		})

		Context("when setting the link up fails", func() {
			BeforeEach(func() {
				linkFactory.SetUpReturns(errors.New("tomato"))
			})

			It("returns a meaningful error", func() {
				err := sb.Setup()
开发者ID:cloudfoundry-incubator,项目名称:ducati-daemon,代码行数:31,代码来源:sandbox_test.go


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