test
This commit is contained in:
@@ -30,15 +30,16 @@ type MockCommandExecutor struct {
|
||||
// Used to stub the return of the Output method
|
||||
// Could add other properties depending on testing needs
|
||||
output string
|
||||
err error
|
||||
}
|
||||
|
||||
// Implements the commandExecutor interface
|
||||
func (m *MockCommandExecutor) Output() ([]byte, error) {
|
||||
return []byte(m.output), nil
|
||||
return []byte(m.output), m.err
|
||||
}
|
||||
|
||||
func (m *MockCommandExecutor) CombinedOutput() ([]byte, error) {
|
||||
return []byte(m.output), nil
|
||||
return []byte(m.output), m.err
|
||||
}
|
||||
|
||||
//
|
||||
@@ -74,7 +75,26 @@ func getCmdsKubectl(mock bool, outputs map[string]string) (KubectlCommand) {
|
||||
cmd := KubectlCommand{Bin: "mock", Exec: mock}
|
||||
return cmd
|
||||
} else {
|
||||
bin := filepath.Join(TEST_BIN_DIR, "Kubectl")
|
||||
bin := filepath.Join(TEST_BIN_DIR, "kubectl")
|
||||
os.Chmod(bin, 0700)
|
||||
|
||||
cmd := KubectlCommand{Bin: bin}
|
||||
cmd.New()
|
||||
return cmd
|
||||
}
|
||||
}
|
||||
|
||||
func getCmdKubectlError(mock bool, output string, err error) (KubectlCommand) {
|
||||
if mock == true {
|
||||
|
||||
mock := func(name string, args ...string) commandExecutor {
|
||||
return &MockCommandExecutor{output: output, err: err}
|
||||
}
|
||||
|
||||
cmd := KubectlCommand{Bin: "mock", Exec: mock}
|
||||
return cmd
|
||||
} else {
|
||||
bin := filepath.Join(TEST_BIN_DIR, "kubectl")
|
||||
os.Chmod(bin, 0700)
|
||||
|
||||
cmd := KubectlCommand{Bin: bin}
|
||||
|
Reference in New Issue
Block a user