本文整理汇总了Golang中github.com/aelsabbahy/goss/system.System.NewCommand方法的典型用法代码示例。如果您正苦于以下问题:Golang System.NewCommand方法的具体用法?Golang System.NewCommand怎么用?Golang System.NewCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/aelsabbahy/goss/system.System
的用法示例。
在下文中一共展示了System.NewCommand方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AppendSysResource
func (r CommandMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*Command, error) {
sysres := sys.NewCommand(sr, sys, config)
res, err := NewCommand(sysres, config)
if err != nil {
return nil, err
}
r[res.ID()] = res
return res, nil
}
示例2: AppendSysResourceIfExists
func (r CommandMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Command, system.Command, bool) {
sysres := sys.NewCommand(sr, sys)
res := NewCommand(sysres)
if e, _ := sysres.Exists(); e != true {
return res, sysres, false
}
r[res.ID()] = res
return res, sysres, true
}
示例3: AppendSysResourceIfExists
func (r CommandMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Command, system.Command, bool) {
sysres := sys.NewCommand(sr, sys, util.Config{})
// FIXME: Do we want to be silent about errors?
res, _ := NewCommand(sysres, util.Config{})
if e, _ := sysres.Exists(); e != true {
return res, sysres, false
}
r[res.ID()] = res
return res, sysres, true
}
示例4: AppendSysResource
func (r CommandMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*Command, error) {
sysres := sys.NewCommand(sr, sys, config)
res, err := NewCommand(sysres, config)
if err != nil {
return nil, err
}
if old_res, ok := r[res.ID()]; ok {
res.Title = old_res.Title
res.Meta = old_res.Meta
}
r[res.ID()] = res
return res, nil
}
示例5: Validate
func (c *Command) Validate(sys *system.System) []TestResult {
syscommand := sys.NewCommand(c.Command, sys)
var results []TestResult
results = append(results, ValidateValue(c, "exit-status", c.ExitStatus, syscommand.ExitStatus))
if len(c.Stdout) > 0 {
results = append(results, ValidateContains(c, "stdout", c.Stdout, syscommand.Stdout))
}
if len(c.Stderr) > 0 {
results = append(results, ValidateContains(c, "stderr", c.Stderr, syscommand.Stderr))
}
return results
}
示例6: Validate
func (c *Command) Validate(sys *system.System) []TestResult {
skip := false
if c.Timeout == 0 {
c.Timeout = 10000
}
sysCommand := sys.NewCommand(c.Command, sys, util.Config{Timeout: c.Timeout})
var results []TestResult
cExitStatus := deprecateAtoI(c.ExitStatus, fmt.Sprintf("%s: command.exit-status", c.Command))
results = append(results, ValidateValue(c, "exit-status", cExitStatus, sysCommand.ExitStatus, skip))
if len(c.Stdout) > 0 {
results = append(results, ValidateContains(c, "stdout", c.Stdout, sysCommand.Stdout, skip))
}
if len(c.Stderr) > 0 {
results = append(results, ValidateContains(c, "stderr", c.Stderr, sysCommand.Stderr, skip))
}
return results
}
示例7: Validate
func (c *Command) Validate(sys *system.System) []TestResult {
if c.Timeout == 0 {
c.Timeout = 10000
}
sysCommand := sys.NewCommand(c.Command, sys, util.Config{Timeout: c.Timeout})
var results []TestResult
results = append(results, ValidateValue(c, "exit-status", c.ExitStatus, sysCommand.ExitStatus))
if len(c.Stdout) > 0 {
results = append(results, ValidateContains(c, "stdout", c.Stdout, sysCommand.Stdout))
}
if len(c.Stderr) > 0 {
results = append(results, ValidateContains(c, "stderr", c.Stderr, sysCommand.Stderr))
}
return results
}
示例8: AppendSysResource
func (r CommandMap) AppendSysResource(sr string, sys *system.System) (*Command, system.Command) {
sysres := sys.NewCommand(sr, sys)
res := NewCommand(sysres)
r[res.ID()] = res
return res, sysres
}