本文整理匯總了Golang中github.com/cloudfoundry/bosh-utils/system.CmdRunner.RunCommand方法的典型用法代碼示例。如果您正苦於以下問題:Golang CmdRunner.RunCommand方法的具體用法?Golang CmdRunner.RunCommand怎麽用?Golang CmdRunner.RunCommand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/bosh-utils/system.CmdRunner
的用法示例。
在下文中一共展示了CmdRunner.RunCommand方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
fs.RemoveAll(dstDir)
})
Describe("CompressFilesInDir", func() {
It("compresses the files in the given directory", func() {
srcDir := fixtureSrcDir()
symlinkPath, err := createTestSymlink()
Expect(err).To(Succeed())
defer os.Remove(symlinkPath)
tgzName, err := compressor.CompressFilesInDir(srcDir)
Expect(err).ToNot(HaveOccurred())
defer os.Remove(tgzName)
tarballContents, _, _, err := cmdRunner.RunCommand("tar", "-tf", tgzName)
Expect(err).ToNot(HaveOccurred())
contentElements := strings.Fields(strings.TrimSpace(tarballContents))
Expect(contentElements).To(ConsistOf(
"./",
"./app.stderr.log",
"./app.stdout.log",
"./other_logs/",
"./some_directory/",
"./some_directory/sub_dir/",
"./some_directory/sub_dir/other_sub_dir/",
"./some_directory/sub_dir/other_sub_dir/.keep",
"./symlink_dir",
"./other_logs/more_logs/",
示例2:
Expect(names).To(HaveKey(p.Name))
Expect(p.State).To(Equal("stopped"))
Expect(int(p.CPU.Total)).To(Equal(0))
Expect(int(p.CPU.Total)).To(Equal(0))
Expect(int(p.Memory.Kb)).To(Equal(0))
}
})
})
Describe("AddJob", func() {
It("creates a service with vcap description", func() {
conf, err := AddJob("say-hello")
Expect(err).ToNot(HaveOccurred())
for _, proc := range conf.Processes {
stdout, _, _, err := runner.RunCommand("powershell", "/C", "get-service", proc.Name)
Expect(err).ToNot(HaveOccurred())
Expect(stdout).To(ContainSubstring(proc.Name))
Expect(stdout).To(ContainSubstring("Stopped"))
}
})
Context("when monit file is empty", func() {
BeforeEach(func() {
Expect(fs.WriteFileString(processConfigPath, "")).To(Succeed())
})
It("does not return an error", func() {
_, err := AddJob("say-hello")
Expect(err).ToNot(HaveOccurred())
})