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


Golang LinkFactory.SetUpReturns方法代码示例

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


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

示例1:

		})

		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()
				Expect(err).To(MatchError("setup failed: set link up: tomato"))
			})
		})
	})

	Describe("Namespace", func() {
		It("returns the sandbox namespace", func() {
			ns := sb.Namespace()
			Expect(ns).To(Equal(sbNamespace))
		})
	})
开发者ID:cloudfoundry-incubator,项目名称:ducati-daemon,代码行数:31,代码来源:sandbox_test.go

示例2:

	})

	Context("when adding the address fails", func() {
		BeforeEach(func() {
			addressManager.AddAddressReturns(errors.New("pineapple"))
		})

		It("returns a meaningful error", func() {
			err := startDNS.Execute(context)
			Expect(err).To(MatchError("namespace execute: add address: pineapple"))
		})
	})

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

		It("returns a meaningful error", func() {
			err := startDNS.Execute(context)
			Expect(err).To(MatchError("namespace execute: set up: pineapple"))
		})
	})

	Context("when creating the listener fails", func() {
		BeforeEach(func() {
			listenerFactory.ListenUDPReturns(nil, errors.New("cantelope"))
		})

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

示例3:

		context.LinkFactoryReturns(linkFactory)

		setLinkUp = commands.SetLinkUp{
			LinkName: "link-name",
		}
	})

	It("sets the link up", func() {
		err := setLinkUp.Execute(context)
		Expect(err).NotTo(HaveOccurred())

		Expect(linkFactory.SetUpCallCount()).To(Equal(1))
		Expect(linkFactory.SetUpArgsForCall(0)).To(Equal("link-name"))
	})

	Context("when setting the link UP fails", func() {
		It("wraps and propagates the error", func() {
			linkFactory.SetUpReturns(errors.New("welp"))

			err := setLinkUp.Execute(context)
			Expect(err).To(MatchError("set link up: welp"))
		})
	})

	Describe("String", func() {
		It("describes itself", func() {
			Expect(setLinkUp.String()).To(Equal("ip link set link-name up"))
		})
	})
})
开发者ID:cloudfoundry-incubator,项目名称:ducati-daemon,代码行数:30,代码来源:set_link_up_test.go


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