本文整理汇总了Golang中github.com/cloudfoundry/gunk/command_runner/fake_command_runner.FakeCommandRunner类的典型用法代码示例。如果您正苦于以下问题:Golang FakeCommandRunner类的具体用法?Golang FakeCommandRunner怎么用?Golang FakeCommandRunner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FakeCommandRunner类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1:
"github.com/cloudfoundry-incubator/garden-linux/linux_container/fake_network_statisticser"
"github.com/cloudfoundry-incubator/garden-linux/linux_container/fake_quota_manager"
"github.com/cloudfoundry-incubator/garden-linux/linux_container/fake_watcher"
networkFakes "github.com/cloudfoundry-incubator/garden-linux/network/fakes"
"github.com/cloudfoundry-incubator/garden-linux/port_pool/fake_port_pool"
"github.com/cloudfoundry-incubator/garden-linux/process_tracker/fake_process_tracker"
wfakes "github.com/cloudfoundry-incubator/garden/fakes"
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
)
var _ = Describe("Linux containers", func() {
var fakeCgroups *fake_cgroups_manager.FakeCgroupsManager
var fakeQuotaManager *fake_quota_manager.FakeQuotaManager
var fakeBandwidthManager *fake_bandwidth_manager.FakeBandwidthManager
var fakeRunner *fake_command_runner.FakeCommandRunner
var containerResources *linux_backend.Resources
var container *linux_container.LinuxContainer
var fakePortPool *fake_port_pool.FakePortPool
var fakeProcessTracker *fake_process_tracker.FakeProcessTracker
var fakeFilter *networkFakes.FakeFilter
var fakeOomWatcher *fake_watcher.FakeWatcher
var containerDir string
var containerProps map[string]string
BeforeEach(func() {
fakeRunner = fake_command_runner.New()
fakeCgroups = fake_cgroups_manager.New("/cgroups", "some-id")
fakeQuotaManager = new(fake_quota_manager.FakeQuotaManager)
开发者ID:guanglinlv,项目名称:garden-linux,代码行数:31,代码来源:linux_container_test.go
示例2:
"code.cloudfoundry.org/lager"
"code.cloudfoundry.org/lager/lagertest"
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
)
var _ = Describe("Create", func() {
var (
fakeRunner *fake_command_runner.FakeCommandRunner
creator *iptables.InstanceChainCreator
bridgeName string
ip net.IP
network *net.IPNet
logger lager.Logger
handle string
)
BeforeEach(func() {
var err error
fakeRunner = fake_command_runner.New()
logger = lagertest.NewTestLogger("test")
handle = "some-handle-that-is-longer-than-29-characters-long"
bridgeName = "some-bridge"
ip, network, err = net.ParseCIDR("1.2.3.4/28")
Expect(err).NotTo(HaveOccurred())
开发者ID:cloudfoundry,项目名称:guardian,代码行数:31,代码来源:instance_chain_creator_test.go
示例3:
"code.cloudfoundry.org/lager/lagertest"
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("RunAndLog", func() {
const logs string = `time="2016-03-02T13:56:38Z" level=warning msg="signal: potato"
time="2016-03-02T13:56:38Z" level=error msg="fork/exec POTATO: no such file or directory"
time="2016-03-02T13:56:38Z" level=fatal msg="Container start failed: [10] System error: fork/exec POTATO: no such file or directory"`
var (
commandRunner *fake_command_runner.FakeCommandRunner
logRunner runrunc.RuncCmdRunner
logger *lagertest.TestLogger
logFile *os.File
)
BeforeEach(func() {
commandRunner = fake_command_runner.New()
logger = lagertest.NewTestLogger("test")
var err error
logFile, err = ioutil.TempFile("", "runandlog")
Expect(err).NotTo(HaveOccurred())
logRunner = runrunc.NewLogRunner(commandRunner, func() (*os.File, error) {
return logFile, nil
})
开发者ID:cloudfoundry,项目名称:guardian,代码行数:31,代码来源:log_test.go
示例4:
"io"
"io/ioutil"
"os/exec"
"code.cloudfoundry.org/guardian/rundmc"
"code.cloudfoundry.org/lager/lagertest"
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
)
var _ = Describe("Nstar", func() {
var (
fakeCommandRunner *fake_command_runner.FakeCommandRunner
nstar rundmc.NstarRunner
)
BeforeEach(func() {
fakeCommandRunner = fake_command_runner.New()
nstar = rundmc.NewNstarRunner(
"path-to-nstar",
"path-to-tar",
fakeCommandRunner,
)
})
Describe("StreamIn", func() {
var someStream io.Reader
BeforeEach(func() {
开发者ID:cloudfoundry,项目名称:guardian,代码行数:32,代码来源:nstar_test.go
示例5:
"code.cloudfoundry.org/lager/lagertest"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"code.cloudfoundry.org/garden"
"code.cloudfoundry.org/guardian/rundmc/runrunc"
fakes "code.cloudfoundry.org/guardian/rundmc/runrunc/runruncfakes"
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
)
var _ = Describe("Stats", func() {
var (
commandRunner *fake_command_runner.FakeCommandRunner
runner *fakes.FakeRuncCmdRunner
runcBinary *fakes.FakeRuncBinary
logger *lagertest.TestLogger
statser *runrunc.Statser
)
BeforeEach(func() {
runcBinary = new(fakes.FakeRuncBinary)
commandRunner = fake_command_runner.New()
runner = new(fakes.FakeRuncCmdRunner)
logger = lagertest.NewTestLogger("test")
statser = runrunc.NewStatser(runner, runcBinary)
runcBinary.StatsCommandStub = func(id string, logFile string) *exec.Cmd {
return exec.Command("funC-stats", "--log", logFile, id)
}
开发者ID:cloudfoundry,项目名称:guardian,代码行数:32,代码来源:stats_test.go
示例6:
"os/exec"
"code.cloudfoundry.org/lager/lagertest"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"code.cloudfoundry.org/guardian/rundmc/runrunc"
fakes "code.cloudfoundry.org/guardian/rundmc/runrunc/runruncfakes"
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
)
var _ = Describe("Watching for Events", func() {
var (
commandRunner *fake_command_runner.FakeCommandRunner
runcBinary *fakes.FakeRuncBinary
logger *lagertest.TestLogger
runner *runrunc.OomWatcher
)
BeforeEach(func() {
runcBinary = new(fakes.FakeRuncBinary)
commandRunner = fake_command_runner.New()
logger = lagertest.NewTestLogger("test")
runner = runrunc.NewOomWatcher(commandRunner, runcBinary)
runcBinary.EventsCommandStub = func(handle string) *exec.Cmd {
return exec.Command("funC-events", "events", handle)
}
})
开发者ID:cloudfoundry,项目名称:guardian,代码行数:31,代码来源:watch_test.go
示例7:
"errors"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"github.com/cloudfoundry-incubator/garden-linux/containerizer"
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("ShellRunnerStep", func() {
var runner *fake_command_runner.FakeCommandRunner
BeforeEach(func() {
runner = fake_command_runner.New()
})
Context("when a given path exists", func() {
var path string
BeforeEach(func() {
tmpdir, err := ioutil.TempDir("", "")
Expect(err).ToNot(HaveOccurred())
path = filepath.Join(tmpdir, "whatever.sh")
Expect(ioutil.WriteFile(path, []byte(""), 0700)).To(Succeed())
})
开发者ID:nagyistoce,项目名称:garden-linux,代码行数:31,代码来源:shell_runner_step_test.go
示例8:
import (
"errors"
"fmt"
"os/exec"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/cloudfoundry-incubator/garden/warden"
"github.com/cloudfoundry-incubator/warden-linux/linux_backend/bandwidth_manager"
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
)
var fakeRunner *fake_command_runner.FakeCommandRunner
var bandwidthManager *bandwidth_manager.ContainerBandwidthManager
var _ = Describe("setting rate limits", func() {
BeforeEach(func() {
fakeRunner = fake_command_runner.New()
bandwidthManager = bandwidth_manager.New("/depot/some-id", "some-id", fakeRunner)
})
It("executes net_rate.sh with the appropriate environment", func() {
limits := warden.BandwidthLimits{
RateInBytesPerSecond: 128,
BurstRateInBytesPerSecond: 256,
}
err := bandwidthManager.SetLimits(limits)
开发者ID:vito,项目名称:warden-docker,代码行数:30,代码来源:bandwidth_manager_test.go
示例9:
"github.com/cloudfoundry-incubator/garden-linux/layercake/fake_cake"
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/pivotal-golang/lager/lagertest"
)
var _ = Describe("BtrfsCleaningCake", func() {
var (
cleaner *layercake.BtrfsCleaningCake
runner *fake_command_runner.FakeCommandRunner
fakeCake *fake_cake.FakeCake
listSubvolumesOutput string
layerId = layercake.DockerImageID("the-layer")
btrfsMountPoint = "/absolute/btrfs_mount"
listSubVolumeErr error
graphDriverErr error
removedDirectories []string
)
BeforeEach(func() {
graphDriverErr = nil
listSubVolumeErr = nil
removedDirectories = []string{}
runner = fake_command_runner.New()
fakeCake = new(fake_cake.FakeCake)
cleaner = &layercake.BtrfsCleaningCake{
开发者ID:guanglinlv,项目名称:garden-linux,代码行数:31,代码来源:btrfs_test.go
示例10:
"net"
"os/exec"
"github.com/cloudfoundry-incubator/garden"
. "github.com/cloudfoundry-incubator/garden-linux/network/iptables"
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
"github.com/pivotal-golang/lager/lagertest"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Iptables", func() {
Describe("Chain", func() {
var fakeRunner *fake_command_runner.FakeCommandRunner
var subject Chain
var useKernelLogging bool
JustBeforeEach(func() {
fakeRunner = fake_command_runner.New()
subject = NewLoggingChain("foo-bar-baz", useKernelLogging, fakeRunner, lagertest.NewTestLogger("test"))
})
Describe("Setup", func() {
Context("when kernel logging is not enabled", func() {
It("creates the log chain using iptables", func() {
Expect(subject.Setup("logPrefix")).To(Succeed())
Expect(fakeRunner).To(HaveExecutedSerially(
fake_command_runner.CommandSpec{
Path: "/sbin/iptables",
开发者ID:nagyistoce,项目名称:garden-linux,代码行数:31,代码来源:iptables_test.go
示例11:
"github.com/cloudfoundry-incubator/garden-linux/process_tracker"
"github.com/cloudfoundry-incubator/garden-linux/process_tracker/fake_process_tracker"
wfakes "github.com/cloudfoundry-incubator/garden/fakes"
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
)
var _ = Describe("Linux containers", func() {
var (
fakeCgroups *fake_cgroups_manager.FakeCgroupsManager
fakeQuotaManager *fake_quota_manager.FakeQuotaManager
fakeBandwidthManager *fake_bandwidth_manager.FakeBandwidthManager
fakeRunner *fake_command_runner.FakeCommandRunner
containerResources *linux_backend.Resources
container *linux_container.LinuxContainer
fakePortPool *fake_port_pool.FakePortPool
fakeProcessTracker *fake_process_tracker.FakeProcessTracker
fakeFilter *networkFakes.FakeFilter
fakeOomWatcher *fake_watcher.FakeWatcher
containerDir string
containerProps map[string]string
containerVersion semver.Version
fakeIPTablesManager *fake_iptables_manager.FakeIPTablesManager
)
netOutRule1 := garden.NetOutRule{
Protocol: garden.ProtocolUDP,
Networks: []garden.IPRange{garden.IPRangeFromIP(net.ParseIP("1.2.3.4"))},
Ports: []garden.PortRange{{Start: 12, End: 24}},
ICMPs: &garden.ICMPControl{Type: 3, Code: garden.ICMPControlCode(12)},
Log: true,
}
开发者ID:nagyistoce,项目名称:garden-linux,代码行数:32,代码来源:snapshotting_test.go
示例12:
BeforeEach(func() {
cake.PathReturns("", testError)
})
It("should return the error", func() {
Expect(aufsCake.Create(namespacedChildID, parentID, "")).To(Equal(testError))
})
It("should not unmount the parent", func() {
Expect(aufsCake.Create(namespacedChildID, parentID, "")).To(Equal(testError))
Expect(cake.UnmountCallCount()).To(Equal(0))
})
})
Context("when getting parent's path succeeds", func() {
var succeedingRunner *fake_command_runner.FakeCommandRunner
BeforeEach(func() {
succeedingRunner = fake_command_runner.New()
succeedingRunner.WhenRunning(fake_command_runner.CommandSpec{}, func(cmd *exec.Cmd) error {
return nil
})
})
It("should unmount the parentID", func() {
aufsCake.Runner = succeedingRunner
Expect(aufsCake.Create(namespacedChildID, parentID, "")).To(Succeed())
Expect(cake.UnmountCallCount()).To(Equal(1))
Expect(cake.UnmountArgsForCall(0)).To(Equal(parentID))
})
开发者ID:cloudfoundry,项目名称:garden-shed,代码行数:30,代码来源:aufs_test.go
示例13:
"errors"
"fmt"
"os"
"os/exec"
"code.cloudfoundry.org/guardian/kawasaki/iptables"
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Setup", func() {
var (
fakeRunner *fake_command_runner.FakeCommandRunner
denyNetworks []string
destroyContainersOnStartup bool
starter *iptables.Starter
)
BeforeEach(func() {
fakeRunner = fake_command_runner.New()
destroyContainersOnStartup = false
})
JustBeforeEach(func() {
fakeLocksmith := NewFakeLocksmith()
starter = iptables.NewStarter(
iptables.New("/sbin/iptables", "/sbin/iptables-restore", fakeRunner, fakeLocksmith, "prefix-"),
true,
"the-nic-prefix",
denyNetworks,
开发者ID:cloudfoundry,项目名称:guardian,代码行数:32,代码来源:global_chains_test.go
示例14:
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
"os"
"net"
networkFakes "github.com/cloudfoundry-incubator/garden-linux/network/fakes"
"github.com/cloudfoundry-incubator/garden-linux/process"
. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Hooks", func() {
var hooks hook.HookSet
var fakeRunner *fake_command_runner.FakeCommandRunner
var config process.Env
var fakeNetworkConfigurer *networkFakes.FakeConfigurer
BeforeEach(func() {
hooks = make(hook.HookSet)
fakeRunner = fake_command_runner.New()
config = process.Env{
"id": "someID",
"network_cidr": "1.2.3.4/8",
"container_iface_mtu": "5000",
"network_container_ip": "1.6.6.6",
"network_host_ip": "1.2.3.5",
"network_host_iface": "hostIfc",
"network_container_iface": "containerIfc",
"bridge_iface": "bridgeName",
开发者ID:nagyistoce,项目名称:garden-linux,代码行数:31,代码来源:hooks_test.go
示例15:
"path/filepath"
"github.com/cloudfoundry-incubator/guardian/kawasaki"
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
"github.com/pivotal-golang/lager"
"github.com/pivotal-golang/lager/lagertest"
. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("NetnsMgr", func() {
var (
fakeRunner *fake_command_runner.FakeCommandRunner
netnsDir string
mgr kawasaki.NetnsMgr
logger lager.Logger
)
BeforeEach(func() {
netnsDir = tmpDir()
logger = lagertest.NewTestLogger("test")
})
JustBeforeEach(func() {
fakeRunner = fake_command_runner.New()
mgr = kawasaki.NewManager(fakeRunner, netnsDir)
})
AfterEach(func() {
os.RemoveAll(netnsDir)
开发者ID:digideskio,项目名称:guardian,代码行数:32,代码来源:netnsmgr_test.go
示例16:
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/st3v/glager"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
)
var _ = Describe("ExternalImageManager", func() {
var (
fakeCommandRunner *fake_command_runner.FakeCommandRunner
logger lager.Logger
externalImageManager *imageplugin.ExternalImageManager
baseImage *url.URL
idMappings []specs.LinuxIDMapping
defaultBaseImage *url.URL
fakeCmdRunnerStdout string
fakeCmdRunnerStderr string
fakeCmdRunnerErr error
)
BeforeEach(func() {
fakeCmdRunnerStdout = ""
fakeCmdRunnerStderr = ""
fakeCmdRunnerErr = nil
logger = glager.NewLogger("external-image-manager")
fakeCommandRunner = fake_command_runner.New()
idMappings = []specs.LinuxIDMapping{
开发者ID:cloudfoundry,项目名称:guardian,代码行数:31,代码来源:external_image_manager_test.go
示例17:
"errors"
"fmt"
"os/exec"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/pivotal-golang/lager/lagertest"
"github.com/cloudfoundry-incubator/garden"
"github.com/cloudfoundry-incubator/garden-linux/linux_container/quota_manager"
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
)
var _ = Describe("btrfs quota manager", func() {
var fakeRunner *fake_command_runner.FakeCommandRunner
var logger *lagertest.TestLogger
var quotaManager *quota_manager.BtrfsQuotaManager
var subvolumePath string
var qgroupShowResponse []byte
var qgroupShowError error
BeforeEach(func() {
fakeRunner = fake_command_runner.New()
logger = lagertest.NewTestLogger("test")
quotaManager = "a_manager.BtrfsQuotaManager{
Runner: fakeRunner,
MountPoint: "/the/mount/point",
}
subvolumePath = "/some/volume/path"
开发者ID:guanglinlv,项目名称:garden-linux,代码行数:31,代码来源:btrfs_quota_manager_test.go
示例18:
"github.com/cloudfoundry-incubator/garden-linux/linux_container/iptables_manager"
"github.com/cloudfoundry-incubator/garden-linux/sysconfig"
. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
"github.com/pivotal-golang/lager/lagertest"
)
var _ = Describe("natChain", func() {
var (
fakeRunner *fake_command_runner.FakeCommandRunner
testCfg *sysconfig.IPTablesNATConfig
chain iptables_manager.Chain
containerID string
bridgeName string
ip net.IP
network *net.IPNet
)
BeforeEach(func() {
var err error
fakeRunner = fake_command_runner.New()
testCfg = &sysconfig.IPTablesNATConfig{
PreroutingChain: "nat-prerouting-chain",
PostroutingChain: "nat-postrouting-chain",
InstancePrefix: "nat-instance-prefix",
}
开发者ID:nagyistoce,项目名称:garden-linux,代码行数:29,代码来源:nat_test.go
示例19:
package fake_command_runner_test
import (
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
"os/exec"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("FakeCommandRunner", func() {
var (
runner *fake_command_runner.FakeCommandRunner
cmd, cmd2 *exec.Cmd
)
BeforeEach(func() {
runner = fake_command_runner.New()
cmd = &exec.Cmd{}
cmd2 = &exec.Cmd{}
})
Describe("Kill", func() {
It("should record Kill commands", func() {
runner.Kill(cmd)
Expect(runner.KilledCommands()).To(Equal([]*exec.Cmd{cmd}))
})
// This may seem like an odd test, but it exposed a bug.
开发者ID:glyn,项目名称:gunk,代码行数:31,代码来源:fake_command_runner_test.go
示例20:
import (
"io/ioutil"
"os"
"os/exec"
"syscall"
"github.com/cloudfoundry-incubator/garden-linux/containerizer/system"
"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Execer", func() {
var execer *system.NamespacingExecer
var commandRunner *fake_command_runner.FakeCommandRunner
BeforeEach(func() {
commandRunner = fake_command_runner.New()
process := &os.Process{
Pid: 12,
}
commandRunner.WhenRunning(fake_command_runner.CommandSpec{}, func(cmd *exec.Cmd) error {
cmd.Process = process
return nil
})
execer = &system.NamespacingExecer{
CommandRunner: commandRunner,
}
开发者ID:nagyistoce,项目名称:garden-linux,代码行数:31,代码来源:namespacing_execer_linux_test.go
注:本文中的github.com/cloudfoundry/gunk/command_runner/fake_command_runner.FakeCommandRunner类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论