本文整理汇总了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())
})