Skip to content
Snippets Groups Projects
Unverified Commit 6ce9ac35 authored by Steve Azzopardi's avatar Steve Azzopardi
Browse files

Add docker machine terminal support

parent 396287b6
No related branches found
No related tags found
No related merge requests found
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")
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment