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


Golang fakes.FakeCmdRunner類代碼示例

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


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

示例1:

package cdrom_test

import (
	"errors"
	. "github.com/cloudfoundry/bosh-agent/platform/cdrom"
	fakeudev "github.com/cloudfoundry/bosh-agent/platform/cdrom/udevdevice/fakes"
	fakesys "github.com/cloudfoundry/bosh-agent/system/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("LinuxCdrom", func() {
	var (
		udev   *fakeudev.FakeUdevDevice
		runner *fakesys.FakeCmdRunner
		cd     Cdrom
	)

	BeforeEach(func() {
		udev = fakeudev.NewFakeUdevDevice()
		runner = fakesys.NewFakeCmdRunner()
	})

	JustBeforeEach(func() {
		cd = NewLinuxCdrom("/dev/sr0", udev, runner)
	})

	Describe("WaitForMedia", func() {
		It("polls the cdrom to force udev to notice it", func() {
			err := cd.WaitForMedia()
			Expect(err).NotTo(HaveOccurred())
開發者ID:keaty,項目名稱:bosh-provisioner,代碼行數:31,代碼來源:linux_cdrom_test.go

示例2:

import (
	"errors"
	"os"

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

	. "github.com/cloudfoundry/bosh-agent/agent/cmdrunner"
	boshsys "github.com/cloudfoundry/bosh-agent/system"
	fakesys "github.com/cloudfoundry/bosh-agent/system/fakes"
)

var _ = Describe("FileLoggingCmdRunner", func() {
	var (
		fs        *fakesys.FakeFileSystem
		cmdRunner *fakesys.FakeCmdRunner
		cmd       boshsys.Command
		runner    CmdRunner
	)

	BeforeEach(func() {
		fs = fakesys.NewFakeFileSystem()
		cmdRunner = fakesys.NewFakeCmdRunner()
		runner = NewFileLoggingCmdRunner(fs, cmdRunner, "/fake-base-dir", 15)

		cmd = boshsys.Command{
			Name:       "fake-cmd",
			Args:       []string{"fake-args"},
			Env:        map[string]string{"fake-env-key": "fake-env-var"},
			WorkingDir: "/fake-working-dir",
		}
	})
開發者ID:keaty,項目名稱:bosh-provisioner,代碼行數:32,代碼來源:file_logging_cmd_runner_test.go

示例3:

	boshlog "github.com/cloudfoundry/bosh-agent/logger"
	. "github.com/cloudfoundry/bosh-agent/platform/net"
	fakearp "github.com/cloudfoundry/bosh-agent/platform/net/arp/fakes"
	fakenet "github.com/cloudfoundry/bosh-agent/platform/net/fakes"
	boship "github.com/cloudfoundry/bosh-agent/platform/net/ip"
	fakeip "github.com/cloudfoundry/bosh-agent/platform/net/ip/fakes"
	boshsettings "github.com/cloudfoundry/bosh-agent/settings"
	fakesys "github.com/cloudfoundry/bosh-agent/system/fakes"
)

var _ = Describe("ubuntuNetManager", func() {
	var (
		fs                     *fakesys.FakeFileSystem
		cmdRunner              *fakesys.FakeCmdRunner
		defaultNetworkResolver *fakenet.FakeDefaultNetworkResolver
		ipResolver             *fakeip.FakeIPResolver
		addressBroadcaster     *fakearp.FakeAddressBroadcaster
		netManager             NetManager
	)

	BeforeEach(func() {
		fs = fakesys.NewFakeFileSystem()
		cmdRunner = fakesys.NewFakeCmdRunner()
		defaultNetworkResolver = &fakenet.FakeDefaultNetworkResolver{}
		ipResolver = &fakeip.FakeIPResolver{}
		addressBroadcaster = &fakearp.FakeAddressBroadcaster{}
		logger := boshlog.NewLogger(boshlog.LevelNone)
		netManager = NewUbuntuNetManager(
			fs,
			cmdRunner,
			defaultNetworkResolver,
開發者ID:keaty,項目名稱:bosh-provisioner,代碼行數:31,代碼來源:ubuntu_net_manager_test.go

示例4:

package disk_test

import (
	"errors"

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

	. "github.com/cloudfoundry/bosh-agent/platform/disk"
	fakesys "github.com/cloudfoundry/bosh-agent/system/fakes"
)

var _ = Describe("cmdMountsSeacher", func() {
	var (
		runner   *fakesys.FakeCmdRunner
		searcher MountsSearcher
	)

	BeforeEach(func() {
		runner = fakesys.NewFakeCmdRunner()
		searcher = NewCmdMountsSearcher(runner)
	})

	Describe("SearchMounts", func() {
		Context("when running command succeeds", func() {
			It("returns parsed mount information", func() {
				runner.AddCmdResult("mount", fakesys.FakeCmdResult{
					Stdout: `devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
/dev/sda1 on /boot type ext2 (rw)
none on /tmp/warden/cgroup type tmpfs (rw)`,
開發者ID:keaty,項目名稱:bosh-provisioner,代碼行數:31,代碼來源:cmd_mounts_searcher_test.go

示例5: JobChange

	jobNextState    string
	jobNextStateErr error
}

func (p fakeDrainParams) JobChange() (change string)       { return p.jobChange }
func (p fakeDrainParams) HashChange() (change string)      { return p.hashChange }
func (p fakeDrainParams) UpdatedPackages() (pkgs []string) { return p.updatedPackages }

func (p fakeDrainParams) JobState() (string, error)     { return p.jobState, p.jobStateErr }
func (p fakeDrainParams) JobNextState() (string, error) { return p.jobNextState, p.jobNextStateErr }

var _ = Describe("ConcreteDrainScript", func() {
	var (
		runner      *fakesys.FakeCmdRunner
		fs          *fakesys.FakeFileSystem
		drainScript ConcreteDrainScript
	)

	BeforeEach(func() {
		fs = fakesys.NewFakeFileSystem()
		runner = fakesys.NewFakeCmdRunner()
		drainScript = NewConcreteDrainScript(fs, runner, "/fake/script")
	})

	Describe("Run", func() {
		var (
			params fakeDrainParams
		)

		BeforeEach(func() {
開發者ID:keaty,項目名稱:bosh-provisioner,代碼行數:30,代碼來源:concrete_drain_script_test.go

示例6:

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

	boshassert "github.com/cloudfoundry/bosh-agent/assert"
	. "github.com/cloudfoundry/bosh-agent/blobstore"
	boshdir "github.com/cloudfoundry/bosh-agent/settings/directories"
	fakesys "github.com/cloudfoundry/bosh-agent/system/fakes"
	fakeuuid "github.com/cloudfoundry/bosh-agent/uuid/fakes"
)

var _ = Describe("externalBlobstore", func() {
	var (
		fs         *fakesys.FakeFileSystem
		runner     *fakesys.FakeCmdRunner
		uuidGen    *fakeuuid.FakeGenerator
		configPath string
		blobstore  Blobstore
	)

	BeforeEach(func() {
		fs = fakesys.NewFakeFileSystem()
		runner = fakesys.NewFakeCmdRunner()
		uuidGen = &fakeuuid.FakeGenerator{}
		dirProvider := boshdir.NewDirectoriesProvider("/var/vcap")
		configPath = filepath.Join(dirProvider.EtcDir(), "blobstore-fake-provider.json")
		blobstore = NewExternalBlobstore("fake-provider", map[string]interface{}{}, fs, runner, uuidGen, configPath)
	})

	Describe("Validate", func() {
		It("external validate writes config file", func() {
開發者ID:keaty,項目名稱:bosh-provisioner,代碼行數:30,代碼來源:external_blobstore_test.go

示例7:

package net_test

import (
	"errors"

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

	. "github.com/cloudfoundry/bosh-agent/platform/net"
	fakesys "github.com/cloudfoundry/bosh-agent/system/fakes"
)

var _ = Describe("cmdRoutesSeacher", func() {
	var (
		runner   *fakesys.FakeCmdRunner
		searcher RoutesSearcher
	)

	BeforeEach(func() {
		runner = fakesys.NewFakeCmdRunner()
		searcher = NewCmdRoutesSearcher(runner)
	})

	Describe("SearchRoutes", func() {
		Context("when running command succeeds", func() {
			It("returns parsed routes information", func() {
				runner.AddCmdResult("route -n", fakesys.FakeCmdResult{
					Stdout: `Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.79.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
開發者ID:keaty,項目名稱:bosh-provisioner,代碼行數:31,代碼來源:cmd_routes_searcher_test.go

示例8:

	s.mounts = s.mounts[1:]
	return result, nil
}

const swaponUsageOutput = `Filename				Type		Size	Used	Priority
/dev/swap                              partition	78180316	0	-1
`

const swaponUsageOutputWithOtherDevice = `Filename				Type		Size	Used	Priority
/dev/swap2                              partition	78180316	0	-1
`

var _ = Describe("linuxMounter", func() {
	var (
		runner         *fakesys.FakeCmdRunner
		mountsSearcher *fakedisk.FakeMountsSearcher
		mounter        Mounter
	)

	BeforeEach(func() {
		runner = fakesys.NewFakeCmdRunner()
		mountsSearcher = &fakedisk.FakeMountsSearcher{}
		mounter = NewLinuxMounter(runner, mountsSearcher, 1*time.Millisecond)
	})

	Describe("Mount", func() {
		It("allows to mount disk at given mount point", func() {
			err := mounter.Mount("/dev/foo", "/mnt/foo")
			Expect(err).ToNot(HaveOccurred())
			Expect(1).To(Equal(len(runner.RunCommands)))
			Expect(runner.RunCommands[0]).To(Equal([]string{"mount", "/dev/foo", "/mnt/foo"}))
開發者ID:keaty,項目名稱:bosh-provisioner,代碼行數:31,代碼來源:linux_mounter_test.go


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