Add docker machine terminal support

parent 396287b6
package machine
import (
"errors"
"gitlab.com/gitlab-org/gitlab-runner/session/terminal"
terminalsession "gitlab.com/gitlab-org/gitlab-runner/session/terminal"
)
func (e *machineExecutor) Connect() (terminalsession.Conn, error) {
if term, ok := e.executor.(terminal.InteractiveTerminal); ok {
return term.Connect()
}
return nil, errors.New("executor does not have terminal")
}
package machine
import (
"testing"
"github.com/stretchr/testify/assert"
"gitlab.com/gitlab-org/gitlab-runner/common"
"gitlab.com/gitlab-org/gitlab-runner/session/terminal"
)
func TestMachineExecutor_Connect_NoTerminal(t *testing.T) {
e := machineExecutor{
executor: &common.MockExecutor{},
}
conn, err := e.Connect()
assert.Error(t, err)
assert.Nil(t, conn)
}
type mockTerminalExecutor struct {
common.MockExecutor
terminal.MockInteractiveTerminal
}
func TestMachineExecutor_Connect_Terminal(t *testing.T) {
mock := mockTerminalExecutor{}
e := machineExecutor{
executor: &mock,
}
mock.MockInteractiveTerminal.On("Connect").Return(&terminal.MockConn{}, nil).Once()
conn, err := e.Connect()
assert.NoError(t, err)
assert.NotNil(t, conn)
mock.MockInteractiveTerminal.AssertCalled(t, "Connect")
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment