當前位置: 首頁>>代碼示例>>Golang>>正文


Golang fakes.Namespace類代碼示例

本文整理匯總了Golang中github.com/cloudfoundry-incubator/ducati-daemon/fakes.Namespace的典型用法代碼示例。如果您正苦於以下問題:Golang Namespace類的具體用法?Golang Namespace怎麽用?Golang Namespace使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Namespace類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1:

	"github.com/cloudfoundry-incubator/ducati-daemon/executor/commands"
	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Start DNS Server", func() {
	var (
		ns               *fakes.Namespace
		context          *fakes.Context
		listenerFactory  *fakes.ListenerFactory
		linkFactory      *fakes.LinkFactory
		addressManager   *fakes.AddressManager
		dnsServerFactory *fakes.DNSServerFactory
		returnedListener *net.UDPConn

		sandboxRepo *fakes.SandboxRepository
		sbox        *fakes.Sandbox
		dnsServer   *fakes.Runner

		startDNS commands.StartDNSServer
	)

	BeforeEach(func() {
		listenerFactory = &fakes.ListenerFactory{}
		linkFactory = &fakes.LinkFactory{}
		addressManager = &fakes.AddressManager{}
		dnsServerFactory = &fakes.DNSServerFactory{}

		ns = &fakes.Namespace{}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:31,代碼來源:start_dns_server_test.go

示例2:

package reloader_test

import (
	"errors"

	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	"github.com/cloudfoundry-incubator/ducati-daemon/reloader"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

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() {
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:31,代碼來源:reloader_test.go

示例3:

import (
	"errors"
	"os"

	"github.com/cloudfoundry-incubator/ducati-daemon/executor/commands"
	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

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))
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:29,代碼來源:in_namespace_test.go

示例4:

		err := mySubscriber.Subscribe(hostNS, neighChan, doneChan)
		Expect(err).NotTo(HaveOccurred())

		_, err = net.Dial("tcp", "172.17.0.105:1234")
		Expect(err).To(HaveOccurred())

		Eventually(neighChan).Should(Receive())
	})
})

var _ = Describe("Subscriber (mock messages)", func() {
	var (
		fakeNetlinker *nlfakes.Netlinker
		fakeSocket    *nlfakes.NLSocket
		targetNS      *fakes.Namespace
		mySubscriber  *subscriber.Subscriber
		neighChan     chan *watcher.Neigh
		doneChan      chan struct{}
		logger        *lagertest.TestLogger
	)

	BeforeEach(func() {
		fakeNetlinker = &nlfakes.Netlinker{}
		fakeSocket = &nlfakes.NLSocket{}
		neighChan = make(chan *watcher.Neigh, 100)
		doneChan = make(chan struct{})
		logger = lagertest.NewTestLogger("test")
		targetNS = &fakes.Namespace{}
		targetNS.ExecuteStub = func(callback func(*os.File) error) error {
			return callback(nil)
		}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:31,代碼來源:subscriber_test.go

示例5:

	"errors"
	"os"

	"github.com/cloudfoundry-incubator/ducati-daemon/executor"
	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	"github.com/pivotal-golang/lager/lagertest"

	. "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,
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:32,代碼來源:namespace_writer_test.go

示例6:

import (
	"errors"
	"os"

	"github.com/cloudfoundry-incubator/ducati-daemon/executor/commands"
	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("StartMonitor", func() {
	var (
		context           *fakes.Context
		sandboxRepository *fakes.Repository
		startMonitor      commands.StartMonitor
		fakeWatcher       *fakes.MissWatcher
		hostNS            *fakes.Namespace

		sandboxNS *fakes.Namespace
	)

	BeforeEach(func() {
		context = &fakes.Context{}
		sandboxRepository = &fakes.Repository{}
		context.SandboxNamespaceRepositoryReturns(sandboxRepository)

		sandboxNS = &fakes.Namespace{}
		sandboxRepository.GetReturns(sandboxNS, nil)

		hostNS = &fakes.Namespace{}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:30,代碼來源:start_monitor_test.go

示例7:

	"github.com/cloudfoundry-incubator/ducati-daemon/lib/neigh"
	nl_fakes "github.com/cloudfoundry-incubator/ducati-daemon/lib/nl/fakes"
	"github.com/cloudfoundry-incubator/ducati-daemon/watcher"
	"github.com/pivotal-golang/lager/lagertest"
	"github.com/vishvananda/netlink"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
)

var _ = Describe("ARPInserter", func() {
	var (
		inserter  *neigh.ARPInserter
		ns        *fakes.Namespace
		netlinker *nl_fakes.Netlinker
		vxlanLink *netlink.Vxlan
		logger    *lagertest.TestLogger
	)

	BeforeEach(func() {
		ns = &fakes.Namespace{}
		netlinker = &nl_fakes.Netlinker{}
		logger = lagertest.NewTestLogger("test")
		vxlanLink = &netlink.Vxlan{
			LinkAttrs: netlink.LinkAttrs{
				Index: 9876,
			},
		}

		ns.ExecuteStub = func(callback func(ns *os.File) error) error {
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:31,代碼來源:arp_inserter_test.go

示例8:

	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	"github.com/cloudfoundry-incubator/ducati-daemon/lib/namespace"
	"github.com/cloudfoundry-incubator/ducati-daemon/watcher"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/pivotal-golang/lager/lagertest"
)

var _ = Describe("Watcher", func() {
	var (
		logger        *lagertest.TestLogger
		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{}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:31,代碼來源:watcher_test.go

示例9:

						},
						commands.MoveLink{
							Name:        "some-vxlan-name",
							SandboxName: "some-sandbox-name",
						},
						commands.StartDNSServer{
							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)
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:30,代碼來源:command_builder_test.go

示例10:

import (
	"errors"
	"os"

	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	"github.com/cloudfoundry-incubator/ducati-daemon/sandbox"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/pivotal-golang/lager/lagertest"
)

var _ = Describe("Sandbox", func() {
	var (
		sb          sandbox.Sandbox
		logger      *lagertest.TestLogger
		sbNamespace *fakes.Namespace
		invoker     *fakes.Invoker
		watcher     *fakes.MissWatcher
		linkFactory *fakes.LinkFactory
	)

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("test")
		invoker = &fakes.Invoker{}
		watcher = &fakes.MissWatcher{}
		linkFactory = &fakes.LinkFactory{}
		sbNamespace = &fakes.Namespace{}
		sbNamespace.ExecuteStub = func(callback func(*os.File) error) error {
			return callback(nil)
		}

		sb = sandbox.New(logger, sbNamespace, invoker, linkFactory, watcher)
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:32,代碼來源:sandbox_test.go

示例11:

	"github.com/cloudfoundry-incubator/ducati-daemon/executor/commands"
	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	"github.com/cloudfoundry-incubator/ducati-daemon/sandbox"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/pivotal-golang/lager/lagertest"
)

var _ = Describe("CleanupSandbox", func() {
	var (
		context               *fakes.Context
		logger                *lagertest.TestLogger
		sbox                  *fakes.Sandbox
		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")
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:30,代碼來源:cleanup_sandbox_test.go

示例12:

	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	"github.com/cloudfoundry-incubator/ducati-daemon/sandbox"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/pivotal-golang/lager/lagertest"
)

var _ = Describe("Sandbox Repository", func() {
	var (
		logger          *lagertest.TestLogger
		locker          *fakes.Locker
		sboxNamespace   *fakes.Namespace
		namespaceRepo   *fakes.Repository
		invoker         *fakes.Invoker
		sandboxRepo     *sandbox.Repository
		linkFactory     *fakes.LinkFactory
		missWatcher     *fakes.MissWatcher
		sandboxCallback *fakes.SandboxCallback
		sandboxFactory  *fakes.SandboxFactory
	)

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("test")
		locker = &fakes.Locker{}
		invoker = &fakes.Invoker{}
		sboxNamespace = &fakes.Namespace{}
		namespaceRepo = &fakes.Repository{}
		namespaceRepo.CreateReturns(sboxNamespace, nil)
		linkFactory = &fakes.LinkFactory{}
		sandboxCallback = &fakes.SandboxCallback{}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:31,代碼來源:repository_test.go


注:本文中的github.com/cloudfoundry-incubator/ducati-daemon/fakes.Namespace類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。