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


Golang fakes.Context類代碼示例

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


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

import (
	"errors"

	"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("MoveLink", func() {
	var (
		context           *fakes.Context
		linkFactory       *fakes.LinkFactory
		sandboxRepository *fakes.SandboxRepository
		sbox              *fakes.Sandbox
		moveLink          commands.MoveLink
	)

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

		linkFactory = &fakes.LinkFactory{}
		context.LinkFactoryReturns(linkFactory)

		sandboxRepository = &fakes.SandboxRepository{}
		context.SandboxRepositoryReturns(sandboxRepository)

		sbox = &fakes.Sandbox{}
		sandboxRepository.GetReturns(sbox, nil)
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:31,代碼來源:move_link_test.go

示例3:

import (
	"errors"

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

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

var _ = Describe("CreateSandbox", func() {
	var (
		context           *fakes.Context
		logger            *lagertest.TestLogger
		sandboxRepository *fakes.SandboxRepository
		sbox              *fakes.Sandbox
		createSandbox     commands.CreateSandbox
	)

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

		logger = lagertest.NewTestLogger("test")
		context.LoggerReturns(logger)

		sandboxRepository = &fakes.SandboxRepository{}
		context.SandboxRepositoryReturns(sandboxRepository)

		createSandbox = commands.CreateSandbox{
			Name: "my-namespace",
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:31,代碼來源:create_sandbox_test.go

示例4:

import (
	"errors"
	"net"

	"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("GetHardwareAddress", func() {
	var (
		context     *fakes.Context
		linkFactory *fakes.LinkFactory
		hwAddr      net.HardwareAddr

		getHWAddress *commands.GetHardwareAddress
	)

	BeforeEach(func() {
		var err error
		hwAddr, err = net.ParseMAC("FF:FF:FF:FF:FF:FF")
		Expect(err).NotTo(HaveOccurred())

		linkFactory = &fakes.LinkFactory{}
		linkFactory.HardwareAddressReturns(hwAddr, nil)

		context = &fakes.Context{}
		context.LinkFactoryReturns(linkFactory)
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:29,代碼來源:get_hardware_address_test.go

示例5:

package commands_test

import (
	"errors"
	"net"

	"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("AddAddress", func() {
	var (
		addressManager *fakes.AddressManager
		context        *fakes.Context
		addAddress     commands.AddAddress
	)

	BeforeEach(func() {
		addressManager = &fakes.AddressManager{}
		context = &fakes.Context{}
		context.AddressManagerReturns(addressManager)

		addAddress = commands.AddAddress{
			InterfaceName: "my-interface",
			Address: net.IPNet{
				IP:   net.ParseIP("192.168.1.1"),
				Mask: net.CIDRMask(24, 32),
			},
		}
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:31,代碼來源:add_address_test.go

示例6:

package conditions_test

import (
	"errors"

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

var _ = Describe("SandboxExists", func() {
	var (
		repo          *fakes.SandboxRepository
		sandboxExists conditions.SandboxExists
		context       *fakes.Context
	)

	BeforeEach(func() {
		repo = &fakes.SandboxRepository{}
		context = &fakes.Context{}
		context.SandboxRepositoryReturns(repo)

		sandboxExists = conditions.SandboxExists{
			Name: "some-sandbox",
		}
	})

	Context("when the namespace exists", func() {
		BeforeEach(func() {
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:31,代碼來源:sandbox_exists_test.go

示例7:

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

示例8:

package commands_test

import (
	"errors"
	"net"

	"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("AddRoute", func() {
	var (
		routeManager *fakes.RouteManager
		context      *fakes.Context
		addRoute     commands.AddRoute
	)

	BeforeEach(func() {
		context = &fakes.Context{}
		routeManager = &fakes.RouteManager{}
		context.RouteManagerReturns(routeManager)

		addRoute = commands.AddRoute{
			Interface: "my-interface",
			Destination: net.IPNet{
				IP:   net.ParseIP("192.168.1.1"),
				Mask: net.CIDRMask(24, 32),
			},
			Gateway: net.ParseIP("192.168.1.4"),
開發者ID:cloudfoundry-incubator,項目名稱:ducati-daemon,代碼行數:31,代碼來源:add_route_test.go

示例9:

	"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


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