本文整理匯總了Golang中bosh/platform/cdutil/fakes.FakeCdUtil類的典型用法代碼示例。如果您正苦於以下問題:Golang FakeCdUtil類的具體用法?Golang FakeCdUtil怎麽用?Golang FakeCdUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了FakeCdUtil類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
fakestats "bosh/platform/stats/fakes"
boshvitals "bosh/platform/vitals"
boshsettings "bosh/settings"
boshdirs "bosh/settings/directories"
fakesys "bosh/system/fakes"
)
var _ = Describe("LinuxPlatform", func() {
var (
collector *fakestats.FakeStatsCollector
fs *fakesys.FakeFileSystem
cmdRunner *fakesys.FakeCmdRunner
diskManager *fakedisk.FakeDiskManager
dirProvider boshdirs.DirectoriesProvider
diskWaitTimeout time.Duration
devicePathResolver *fakedpresolv.FakeDevicePathResolver
platform Platform
cdutil *fakecd.FakeCdUtil
compressor boshcmd.Compressor
copier boshcmd.Copier
vitalsService boshvitals.Service
netManager *fakenet.FakeNetManager
options LinuxOptions
)
BeforeEach(func() {
logger := boshlog.NewLogger(boshlog.LevelNone)
collector = &fakestats.FakeStatsCollector{}
fs = fakesys.NewFakeFileSystem()
cmdRunner = fakesys.NewFakeCmdRunner()
diskManager = fakedisk.NewFakeDiskManager()
示例2: init
func init() {
Describe("Testing with Ginkgo", func() {
var (
collector *fakestats.FakeStatsCollector
fs *fakesys.FakeFileSystem
cmdRunner *fakesys.FakeCmdRunner
diskManager fakedisk.FakeDiskManager
dirProvider boshdirs.DirectoriesProvider
diskWaitTimeout time.Duration
platform Platform
cdutil *fakecd.FakeCdUtil
compressor boshcmd.Compressor
copier boshcmd.Copier
vitalsService boshvitals.Service
)
BeforeEach(func() {
collector = &fakestats.FakeStatsCollector{}
fs = &fakesys.FakeFileSystem{}
cmdRunner = &fakesys.FakeCmdRunner{}
diskManager = fakedisk.NewFakeDiskManager(cmdRunner)
dirProvider = boshdirs.NewDirectoriesProvider("/fake-dir")
diskWaitTimeout = 1 * time.Millisecond
cdutil = fakecd.NewFakeCdUtil()
compressor = boshcmd.NewTarballCompressor(cmdRunner, fs)
copier = boshcmd.NewCpCopier(cmdRunner, fs)
vitalsService = boshvitals.NewService(collector, dirProvider)
})
JustBeforeEach(func() {
netManager := boshnet.NewUbuntuNetManager(fs, cmdRunner, 1*time.Millisecond)
platform = NewLinuxPlatform(
fs,
cmdRunner,
collector,
compressor,
copier,
dirProvider,
vitalsService,
cdutil,
diskManager,
diskWaitTimeout,
netManager,
)
})
It("ubuntu setup runtime configuration", func() {
err := platform.SetupRuntimeConfiguration()
assert.NoError(GinkgoT(), err)
assert.Equal(GinkgoT(), 1, len(cmdRunner.RunCommands))
assert.Equal(GinkgoT(), []string{"bosh-agent-rc"}, cmdRunner.RunCommands[0])
})
It("ubuntu create user", func() {
expectedUseradd := []string{
"useradd",
"-m",
"-b", "/some/path/to/home",
"-s", "/bin/bash",
"-p", "bar-pwd",
"foo-user",
}
password := "bar-pwd"
err := platform.CreateUser("foo-user", password, "/some/path/to/home")
assert.NoError(GinkgoT(), err)
basePathStat := fs.GetFileTestStat("/some/path/to/home")
assert.Equal(GinkgoT(), fakesys.FakeFileTypeDir, basePathStat.FileType)
assert.Equal(GinkgoT(), os.FileMode(0755), basePathStat.FileMode)
assert.Equal(GinkgoT(), 1, len(cmdRunner.RunCommands))
assert.Equal(GinkgoT(), expectedUseradd, cmdRunner.RunCommands[0])
})
It("ubuntu create user with an empty password", func() {
expectedUseradd := []string{
"useradd",
"-m",
"-b", "/some/path/to/home",
"-s", "/bin/bash",
"foo-user",
}
password := ""
err := platform.CreateUser("foo-user", password, "/some/path/to/home")
assert.NoError(GinkgoT(), err)
basePathStat := fs.GetFileTestStat("/some/path/to/home")
assert.Equal(GinkgoT(), fakesys.FakeFileTypeDir, basePathStat.FileType)
assert.Equal(GinkgoT(), os.FileMode(0755), basePathStat.FileMode)
assert.Equal(GinkgoT(), 1, len(cmdRunner.RunCommands))
assert.Equal(GinkgoT(), expectedUseradd, cmdRunner.RunCommands[0])
})
It("ubuntu add user to groups", func() {
//.........這裏部分代碼省略.........