Skip to content
Snippets Groups Projects
Commit 18862634 authored by Kamil Trzciński's avatar Kamil Trzciński
Browse files

Merge branch '3467-add-docker-machine-support-for-interactive-web-terminal' into 'master'

Add support docker machine web terminal support

Closes #3467

See merge request gitlab-org/gitlab-runner!1046
parents a36753db 6ce9ac35
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