本文整理匯總了Golang中bosh/system/fakes.FakeCmdRunner.CommandExistsValue方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeCmdRunner.CommandExistsValue方法的具體用法?Golang FakeCmdRunner.CommandExistsValue怎麽用?Golang FakeCmdRunner.CommandExistsValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bosh/system/fakes.FakeCmdRunner
的用法示例。
在下文中一共展示了FakeCmdRunner.CommandExistsValue方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
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() {
options := map[string]interface{}{"fake-key": "fake-value"}
blobstore := NewExternalBlobstore("fake-provider", options, fs, runner, uuidGen, configPath)
runner.CommandExistsValue = true
err := blobstore.Validate()
Expect(err).ToNot(HaveOccurred())
s3CliConfig, err := fs.ReadFileString(configPath)
Expect(err).ToNot(HaveOccurred())
expectedJSON := map[string]string{"fake-key": "fake-value"}
boshassert.MatchesJSONString(GinkgoT(), expectedJSON, s3CliConfig)
})
It("external validate errors when command not in path", func() {
options := map[string]interface{}{}
blobstore := NewExternalBlobstore("fake-provider", options, fs, runner, uuidGen, configPath)
示例2: init
//.........這裏部分代碼省略.........
ItUpdatesDhcp3Config := func() {
It("updates /etc/dhcp3/dhclient.conf", func() {
err := netManager.SetupDhcp(networks)
Expect(err).ToNot(HaveOccurred())
dhcpConfig := fs.GetFileTestStat("/etc/dhcp3/dhclient.conf")
Expect(dhcpConfig).ToNot(BeNil())
Expect(dhcpConfig.StringContents()).To(Equal(expectedUbuntuDHCPConfig))
})
}
ItUpdatesDhcpConfig := func() {
It("updates /etc/dhcp/dhclient.conf", func() {
err := netManager.SetupDhcp(networks)
Expect(err).ToNot(HaveOccurred())
dhcpConfig := fs.GetFileTestStat("/etc/dhcp/dhclient.conf")
Expect(dhcpConfig).ToNot(BeNil())
Expect(dhcpConfig.StringContents()).To(Equal(expectedUbuntuDHCPConfig))
})
}
ItDoesNotRestartDhcp := func() {
It("does not restart dhclient", func() {
err := netManager.SetupDhcp(networks)
Expect(err).ToNot(HaveOccurred())
Expect(len(cmdRunner.RunCommands)).To(Equal(0))
})
}
Context("when dhclient3 is installed on the system", func() {
BeforeEach(func() { cmdRunner.CommandExistsValue = true })
Context("when dhcp was not previously configured", func() {
ItUpdatesDhcp3Config()
ItRestartsDhcp()
})
Context("when dhcp was previously configured with different configuration", func() {
BeforeEach(func() {
fs.WriteFileString("/etc/dhcp3/dhclient.conf", "fake-other-configuration")
})
ItUpdatesDhcp3Config()
ItRestartsDhcp()
})
Context("when dhcp was previously configured with the same configuration", func() {
BeforeEach(func() {
fs.WriteFileString("/etc/dhcp3/dhclient.conf", expectedUbuntuDHCPConfig)
})
ItUpdatesDhcp3Config()
ItDoesNotRestartDhcp()
})
})
Context("when dhclient3 is not installed on the system", func() {
BeforeEach(func() { cmdRunner.CommandExistsValue = false })
Context("when dhcp was not previously configured", func() {
ItUpdatesDhcpConfig()
ItRestartsDhcp()
})
示例3:
It("starts broadcasting the MAC addresses", func() {
errCh := make(chan error)
err := netManager.SetupDhcp(networks, errCh)
Expect(err).ToNot(HaveOccurred())
<-errCh // wait for all arpings
Expect(addressBroadcaster.BroadcastMACAddressesAddresses).To(Equal([]boship.InterfaceAddress{
boship.NewResolvingInterfaceAddress("eth0", ipResolver),
}))
})
}
Context("when dhclient3 is installed on the system", func() {
BeforeEach(func() { cmdRunner.CommandExistsValue = true })
Context("when dhcp was not previously configured", func() {
ItUpdatesDhcpConfig(dhcp3ConfPath)
ItRestartsDhcp()
ItBroadcastsMACAddresses()
})
Context("when dhcp was previously configured with different configuration", func() {
BeforeEach(func() {
fs.WriteFileString(dhcp3ConfPath, "fake-other-configuration")
})
ItUpdatesDhcpConfig(dhcp3ConfPath)
ItRestartsDhcp()
ItBroadcastsMACAddresses()