本文整理匯總了Golang中github.com/cloudfoundry-incubator/ducati-daemon/fakes.Namespace.MarshalJSONReturns方法的典型用法代碼示例。如果您正苦於以下問題:Golang Namespace.MarshalJSONReturns方法的具體用法?Golang Namespace.MarshalJSONReturns怎麽用?Golang Namespace.MarshalJSONReturns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry-incubator/ducati-daemon/fakes.Namespace
的用法示例。
在下文中一共展示了Namespace.MarshalJSONReturns方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
)
var _ = Describe("NamespaceWriter", func() {
var (
nsWriter *executor.NamespaceWriter
ns *fakes.Namespace
writer *fakes.Writer
logger *lagertest.TestLogger
)
BeforeEach(func() {
ns = &fakes.Namespace{}
ns.MarshalJSONReturns([]byte(`{ "namespace": "my-namespace", "inode": "some-inode" }`), nil)
ns.ExecuteStub = func(callback func(*os.File) error) error {
return callback(nil)
}
logger = lagertest.NewTestLogger("test")
writer = &fakes.Writer{}
nsWriter = &executor.NamespaceWriter{
Logger: logger,
Namespace: ns,
Writer: writer,
}
})
It("writes to the wrapped writer in the associated namespace", func() {
示例2:
locker *fakes.Locker
sub *fakes.Subscriber
ns *fakes.Namespace
vxlanLinkName string
resolver *fakes.Resolver
missWatcher watcher.MissWatcher
arpInserter *fakes.ARPInserter
)
BeforeEach(func() {
sub = &fakes.Subscriber{}
logger = lagertest.NewTestLogger("test")
locker = &fakes.Locker{}
ns = &fakes.Namespace{}
ns.MarshalJSONReturns([]byte("{}"), nil)
vxlanLinkName = "some-vxlan-name"
resolver = &fakes.Resolver{}
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)