Fixed integration tests, adding test output to ssh mock, change help text to use multi-line string and
updated docs.pull/520/head
parent
3ef433d259
commit
6017e34d4d
|
@ -72,6 +72,8 @@ var statusCmd = &cobra.Command{
|
|||
}
|
||||
|
||||
func init() {
|
||||
statusCmd.Flags().StringVar(&statusFormat, "format", constants.DefaultStatusFormat, "Go template format string for the status output. Go templates format can be found here: https://golang.org/pkg/text/template/\nFor the list accessible variables for the template, see the struct values here:https://godoc.org/k8s.io/minikube/cmd/minikube/cmd#Status")
|
||||
statusCmd.Flags().StringVar(&statusFormat, "format", constants.DefaultStatusFormat,
|
||||
`Go template format string for the status output. The format for Go templates can be found here: https://golang.org/pkg/text/template/
|
||||
For the list accessible variables for the template, see the struct values here:https://godoc.org/k8s.io/minikube/cmd/minikube/cmd#Status`)
|
||||
RootCmd.AddCommand(statusCmd)
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ minikube status
|
|||
### Options
|
||||
|
||||
```
|
||||
--format="minikubeVM: {{.MinikubeStatus}}\nlocalkube: {{.LocalkubeStatus}}\n": Go template format string for the status output. Go templates format can be found here: https://golang.org/pkg/text/template/
|
||||
--format="minikubeVM: {{.MinikubeStatus}}\nlocalkube: {{.LocalkubeStatus}}\n": Go template format string for the status output. The format for Go templates can be found here: https://golang.org/pkg/text/template/
|
||||
For the list accessible variables for the template, see the struct values here:https://godoc.org/k8s.io/minikube/cmd/minikube/cmd#Status
|
||||
```
|
||||
|
||||
|
|
|
@ -157,9 +157,6 @@ func GetLocalkubeStatus(api libmachine.API) (string, error) {
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if s == "" { // this is a test pass through, I am not sure what I should do here
|
||||
return "N/A", nil
|
||||
}
|
||||
s = strings.TrimSpace(s)
|
||||
if state.Running.String() == s {
|
||||
return state.Running.String(), nil
|
||||
|
|
|
@ -343,12 +343,25 @@ func TestGetLocalkubeStatus(t *testing.T) {
|
|||
}
|
||||
api.Hosts[constants.MachineName] = &host.Host{Driver: d}
|
||||
|
||||
s.CommandToOutput = map[string]string{
|
||||
localkubeStatusCommand: state.Running.String(),
|
||||
}
|
||||
if _, err := GetLocalkubeStatus(api); err != nil {
|
||||
t.Fatalf("Error getting localkube status: %s", err)
|
||||
}
|
||||
|
||||
if _, ok := s.Commands[localkubeStatusCommand]; !ok {
|
||||
t.Fatalf("Expected command not run: %s", logsCommand)
|
||||
s.CommandToOutput = map[string]string{
|
||||
localkubeStatusCommand: state.Stopped.String(),
|
||||
}
|
||||
if _, err := GetLocalkubeStatus(api); err != nil {
|
||||
t.Fatalf("Error getting localkube status: %s", err)
|
||||
}
|
||||
|
||||
s.CommandToOutput = map[string]string{
|
||||
localkubeStatusCommand: "Bad Output",
|
||||
}
|
||||
if _, err := GetLocalkubeStatus(api); err == nil {
|
||||
t.Fatalf("Expected error in getting localkube status as ssh returned bad output")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ type SSHServer struct {
|
|||
Connected bool
|
||||
Transfers *bytes.Buffer
|
||||
HadASessionRequested bool
|
||||
CommandToOutput map[string]string
|
||||
}
|
||||
|
||||
// NewSSHServer returns a NewSSHServer instance, ready for use.
|
||||
|
@ -107,6 +108,11 @@ func (s *SSHServer) Start() (int, error) {
|
|||
return
|
||||
}
|
||||
s.Commands[cmd.Command] = 1
|
||||
|
||||
// Write specified command output as mocked ssh output
|
||||
if val, ok := s.CommandToOutput[cmd.Command]; ok {
|
||||
channel.Write([]byte(val))
|
||||
}
|
||||
channel.SendRequest("exit-status", false, []byte{0, 0, 0, 0})
|
||||
|
||||
// Store anything that comes in over stdin.
|
||||
|
|
|
@ -100,8 +100,7 @@ func (m *MinikubeRunner) SetEnvFromEnvCmdOutput(dockerEnvVars string) error {
|
|||
}
|
||||
|
||||
func (m *MinikubeRunner) GetStatus() string {
|
||||
status := m.RunCommand("status", true)
|
||||
return strings.Trim(status, "\n")
|
||||
return m.RunCommand("status --format={{.MinikubeStatus}}", true)
|
||||
}
|
||||
|
||||
func (m *MinikubeRunner) CheckStatus(desired string) {
|
||||
|
|
Loading…
Reference in New Issue