本文整理匯總了Golang中github.com/cloudfoundry-incubator/ducati-daemon/fakes.Namespace.NameReturns方法的典型用法代碼示例。如果您正苦於以下問題:Golang Namespace.NameReturns方法的具體用法?Golang Namespace.NameReturns怎麽用?Golang Namespace.NameReturns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry-incubator/ducati-daemon/fakes.Namespace
的用法示例。
在下文中一共展示了Namespace.NameReturns方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
var _ = Describe("ExecuteInNamespace", func() {
var (
context *fakes.Context
namespace *fakes.Namespace
command *fakes.Command
inNamespace commands.InNamespace
)
BeforeEach(func() {
context = &fakes.Context{}
command = &fakes.Command{}
command.StringReturns("some-command")
namespace = &fakes.Namespace{}
namespace.NameReturns("namespace-name")
namespace.ExecuteStub = func(callback func(*os.File) error) error {
Expect(command.ExecuteCallCount()).To(Equal(0))
err := callback(nil)
Expect(command.ExecuteCallCount()).To(Equal(1))
return err
}
inNamespace = commands.InNamespace{
Namespace: namespace,
Command: command,
}
})
示例2:
var _ = Describe("Reloader", func() {
var (
monitorReloader *reloader.Reloader
watcher *fakes.MissWatcher
ns *fakes.Namespace
)
BeforeEach(func() {
watcher = &fakes.MissWatcher{}
monitorReloader = &reloader.Reloader{
Watcher: watcher,
}
ns = &fakes.Namespace{}
ns.NameReturns("/some/sbox/path/vni-some-sandbox")
})
Describe("Callback", func() {
It("restart the monitor for the given namespace", func() {
err := monitorReloader.Callback(ns)
Expect(err).NotTo(HaveOccurred())
Expect(watcher.StartMonitorCallCount()).To(Equal(1))
calledNS, vxlanDev := watcher.StartMonitorArgsForCall(0)
Expect(calledNS).To(Equal(ns))
Expect(vxlanDev).To(Equal("vxlansome-sandbox"))
})
Context("failure cases", func() {
It("returns an error when the sandbox name is not valid", func() {
示例3:
arpInserter = &fakes.ARPInserter{}
arpInserter.HandleResolvedNeighborsStub = func(ready chan error, _ namespace.Namespace, _ string, _ <-chan watcher.Neighbor) {
close(ready)
}
missWatcher = watcher.New(logger, sub, locker, resolver, arpInserter)
ns.ExecuteStub = func(callback func(ns *os.File) error) error {
err := callback(nil)
if err != nil {
return fmt.Errorf("callback failed: %s", err)
}
return nil
}
ns.NameReturns("some-namespace")
})
Describe("StartMonitor", func() {
It("subscribes to sandbox l3 misses", func() {
missWatcher.StartMonitor(ns, vxlanLinkName)
Expect(sub.SubscribeCallCount()).To(Equal(1))
targetNS, _, doneCh := sub.SubscribeArgsForCall(0)
Expect(targetNS).To(Equal(ns))
Consistently(doneCh).ShouldNot(BeClosed())
})
It("logs entry and exit", func() {
missWatcher.StartMonitor(ns, vxlanLinkName)
示例4:
SandboxName: "some-sandbox-name",
ListenAddress: "some-dns-address",
},
),
}))
})
})
Describe("IdempotentlyCreateVxlan", func() {
var sandboxNS *fakes.Namespace
It("should return a command group that idempotently creates the vxlan device", func() {
hostNamespace := &fakes.Namespace{NameStub: func() string { return "host namespace sentinel" }}
sandboxNS = &fakes.Namespace{}
sandboxNS.NameReturns("/sandbox/repo/some-sandbox-name")
missWatcher := &fakes.MissWatcher{}
b := container.CommandBuilder{
HostNamespace: hostNamespace,
MissWatcher: missWatcher,
}
cmd := b.IdempotentlyCreateVxlan("some-vxlan-name", "some-sandbox-name", sandboxNS)
Expect(cmd).To(Equal(
commands.All(
commands.InNamespace{
Namespace: sandboxNS,
Command: commands.SetLinkUp{
LinkName: "some-vxlan-name",
示例5:
sandboxNS *fakes.Namespace
linkFactory *fakes.LinkFactory
cleanupSandboxCommand commands.CleanupSandbox
missWatcher *fakes.MissWatcher
namespaceRepository *fakes.Repository
sandboxRepo *fakes.SandboxRepository
)
BeforeEach(func() {
context = &fakes.Context{}
logger = lagertest.NewTestLogger("test")
context.LoggerReturns(logger)
sandboxNS = &fakes.Namespace{}
sandboxNS.NameReturns("sandbox-name")
sbox = &fakes.Sandbox{}
sbox.NamespaceReturns(sandboxNS)
linkFactory = &fakes.LinkFactory{}
context.LinkFactoryReturns(linkFactory)
missWatcher = &fakes.MissWatcher{}
namespaceRepository = &fakes.Repository{}
sandboxRepo = &fakes.SandboxRepository{}
sandboxRepo.GetStub = func(key string) (sandbox.Sandbox, error) {
if key == "sandbox-name" {
return sbox, nil
}
return nil, sandbox.NotFoundError
示例6:
Invoker: invoker,
LinkFactory: linkFactory,
Watcher: missWatcher,
SandboxFactory: sandboxFactory,
Sandboxes: map[string]sandbox.Sandbox{},
}
})
Describe("ForEach", func() {
BeforeEach(func() {
sbox, err := sandboxRepo.Create("some-sandbox-name")
Expect(err).NotTo(HaveOccurred())
Expect(sbox).NotTo(BeNil())
sandboxCallback.CallbackReturns(nil)
sboxNamespace.NameReturns("some-sandbox-name")
})
It("executes the callback for each sandbox in the repo", func() {
err := sandboxRepo.ForEach(sandboxCallback)
Expect(err).NotTo(HaveOccurred())
Expect(sandboxCallback.CallbackCallCount()).To(Equal(1))
ns := sandboxCallback.CallbackArgsForCall(0)
Expect(ns).To(Equal(sboxNamespace))
})
It("locks and unlocks", func() {
Expect(locker.LockCallCount()).To(Equal(1))
Expect(locker.UnlockCallCount()).To(Equal(1))