本文整理汇总了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))
})
})
示例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)
示例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"))
})
})
})