代码拉取完成,页面将自动刷新
//Package provisiontest provides utilities for testing provisioners
package provisiontest
import "errors"
//FakeSSHCommanderOptions is intended to create a FakeSSHCommander without actually knowing the underlying sshcommands by passing it to NewSSHCommander
type FakeSSHCommanderOptions struct {
//Result of the ssh command to look up the FilesystemType
FilesystemType string
}
//FakeSSHCommander is an implementation of provision.SSHCommander to provide predictable responses set by testing code
//Extend it when needed
type FakeSSHCommander struct {
Responses map[string]string
}
//NewFakeSSHCommander creates a FakeSSHCommander without actually knowing the underlying sshcommands
func NewFakeSSHCommander(options FakeSSHCommanderOptions) *FakeSSHCommander {
if options.FilesystemType == "" {
options.FilesystemType = "ext4"
}
sshCmder := &FakeSSHCommander{
Responses: map[string]string{
"stat -f -c %T /var/lib": options.FilesystemType + "\n",
},
}
return sshCmder
}
//SSHCommand is an implementation of provision.SSHCommander.SSHCommand to provide predictable responses set by testing code
func (sshCmder *FakeSSHCommander) SSHCommand(args string) (string, error) {
response, commandRegistered := sshCmder.Responses[args]
if !commandRegistered {
return "", errors.New("Command not registered in FakeSSHCommander")
}
return response, nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。