當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。