107 lines
2.9 KiB
Go
107 lines
2.9 KiB
Go
package pwd
|
|
|
|
import (
|
|
"io"
|
|
"net"
|
|
"time"
|
|
|
|
"github.com/play-with-docker/play-with-docker/pwd/types"
|
|
"github.com/stretchr/testify/mock"
|
|
)
|
|
|
|
type Mock struct {
|
|
mock.Mock
|
|
}
|
|
|
|
func (m *Mock) SessionNew(duration time.Duration, stack string, stackName, imageName string) (*types.Session, error) {
|
|
args := m.Called(duration, stack, stackName, imageName)
|
|
return args.Get(0).(*types.Session), args.Error(1)
|
|
}
|
|
|
|
func (m *Mock) SessionClose(session *types.Session) error {
|
|
args := m.Called(session)
|
|
return args.Error(0)
|
|
}
|
|
|
|
func (m *Mock) SessionGetSmallestViewPort(sessionId string) types.ViewPort {
|
|
args := m.Called(sessionId)
|
|
return args.Get(0).(types.ViewPort)
|
|
}
|
|
|
|
func (m *Mock) SessionDeployStack(session *types.Session) error {
|
|
args := m.Called(session)
|
|
return args.Error(0)
|
|
}
|
|
|
|
func (m *Mock) SessionGet(id string) *types.Session {
|
|
args := m.Called(id)
|
|
return args.Get(0).(*types.Session)
|
|
}
|
|
|
|
func (m *Mock) SessionSetup(session *types.Session, conf SessionSetupConf) error {
|
|
args := m.Called(session, conf)
|
|
return args.Error(0)
|
|
}
|
|
|
|
func (m *Mock) InstanceNew(session *types.Session, conf types.InstanceConfig) (*types.Instance, error) {
|
|
args := m.Called(session, conf)
|
|
return args.Get(0).(*types.Instance), args.Error(1)
|
|
}
|
|
|
|
func (m *Mock) InstanceResizeTerminal(instance *types.Instance, cols, rows uint) error {
|
|
args := m.Called(instance, cols, rows)
|
|
return args.Error(0)
|
|
}
|
|
|
|
func (m *Mock) InstanceGetTerminal(instance *types.Instance) (net.Conn, error) {
|
|
args := m.Called(instance)
|
|
return args.Get(0).(net.Conn), args.Error(1)
|
|
}
|
|
|
|
func (m *Mock) InstanceUploadFromUrl(instance *types.Instance, fileName, dest, url string) error {
|
|
args := m.Called(instance, fileName, dest, url)
|
|
return args.Error(0)
|
|
}
|
|
|
|
func (m *Mock) InstanceUploadFromReader(instance *types.Instance, fileName, dest string, reader io.Reader) error {
|
|
args := m.Called(instance, fileName, dest, reader)
|
|
return args.Error(0)
|
|
}
|
|
|
|
func (m *Mock) InstanceGet(session *types.Session, name string) *types.Instance {
|
|
args := m.Called(session, name)
|
|
return args.Get(0).(*types.Instance)
|
|
}
|
|
func (m *Mock) InstanceFindBySession(session *types.Session) ([]*types.Instance, error) {
|
|
args := m.Called(session)
|
|
return args.Get(0).([]*types.Instance), args.Error(1)
|
|
}
|
|
|
|
func (m *Mock) InstanceDelete(session *types.Session, instance *types.Instance) error {
|
|
args := m.Called(session, instance)
|
|
return args.Error(0)
|
|
}
|
|
|
|
func (m *Mock) InstanceExec(instance *types.Instance, cmd []string) (int, error) {
|
|
args := m.Called(instance, cmd)
|
|
return args.Int(0), args.Error(1)
|
|
}
|
|
|
|
func (m *Mock) ClientNew(id string, session *types.Session) *types.Client {
|
|
args := m.Called(id, session)
|
|
return args.Get(0).(*types.Client)
|
|
}
|
|
|
|
func (m *Mock) ClientResizeViewPort(client *types.Client, cols, rows uint) {
|
|
m.Called(client, cols, rows)
|
|
}
|
|
|
|
func (m *Mock) ClientClose(client *types.Client) {
|
|
m.Called(client)
|
|
}
|
|
|
|
func (m *Mock) ClientCount() int {
|
|
args := m.Called()
|
|
return args.Int(0)
|
|
}
|