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


Golang Namespace.MarshalJSONReturns方法代码示例

本文整理汇总了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() {
开发者ID:cloudfoundry-incubator,项目名称:ducati-daemon,代码行数:31,代码来源:namespace_writer_test.go

示例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)
开发者ID:cloudfoundry-incubator,项目名称:ducati-daemon,代码行数:31,代码来源:watcher_test.go


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