func TestClient_Exec_Resize(t *testing.T) {
	t.Parallel()
	client, fake := testClient()
	fakeOp := &lxdfakes.FakeOperation{}
	resize := make(chan remotecommand.TerminalSize)
	fakeSes := &session{resize: resize}
	var fakeControl *websocket.Conn
	fake.ExecContainerCalls(func(arg1 string, arg2 lxdApi.ContainerExecPost, arg3 *lxd.ContainerExecArgs) (lxd.Operation, error) {
		arg3.Control = fakeSes.controlHandler
		arg3.Control(fakeControl)
		go sendDataDone(arg3, 0)
		return fakeOp, nil
	})
	fakeOp.WaitReturns(nil)
	fakeOp.GetReturns(lxdApi.Operation{
		Metadata: map[string]interface{}{
			"return": float64(0),
		},
	})
	exitCode, err := client.Exec("", nil, nil, nil, nil, false, false, 0, fakeSes.resize)
	assert.NoError(t, err)
	assert.Equal(t, CodeExecOk, exitCode)
	resizeConsumed := make(chan bool)
	go func() {
		resize <- remotecommand.TerminalSize{Width: 60, Height: 40}
		resizeConsumed <- true
	}()
	<-resizeConsumed
}
TODO: Test timeout correctly including control websocket
package lxf
import (
	"strconv"
	"sync"
	"testing"
	"time"
	"github.com/automaticserver/lxe/lxf/lxdfakes"
	"github.com/gorilla/websocket"
	lxd "github.com/lxc/lxd/client"
	lxdApi "github.com/lxc/lxd/shared/api"
	"github.com/stretchr/testify/assert"
	"k8s.io/client-go/tools/remotecommand"
)
func TestClient_Exec_BasicOk(t *testing.T) {
	t.Parallel()
	client, fake := testClient()
	fakeOp := &lxdfakes.FakeOperation{}
	fake.ExecContainerCalls(func(arg1 string, arg2 lxdApi.ContainerExecPost, arg3 *lxd.ContainerExecArgs) (lxd.Operation, error) {
		go sendDataDone(arg3, 0)
		return fakeOp, nil
	})
	fakeOp.WaitReturns(nil)
	fakeOp.GetReturns(lxdApi.Operation{
		Metadata: map[string]interface{}{
			"return": float64(CodeExecError),
		},
	})
	exitCode, err := client.Exec("", nil, nil, nil, nil, false, false, 0, nil)
	assert.NoError(t, err)
	assert.Equal(t, CodeExecError, exitCode)
}
func TestClient_Exec_Timeout(t *testing.T) {
	t.Parallel()
	client, fake := testClient()
	fakeOp := &lxdfakes.FakeOperation{}
	fakeSes := &session{}
	var fakeControl *websocket.Conn
	fake.ExecContainerCalls(func(arg1 string, arg2 lxdApi.ContainerExecPost, arg3 *lxd.ContainerExecArgs) (lxd.Operation, error) {
		arg3.Control = fakeSes.controlHandler
		arg3.Control(fakeControl)
		go sendDataDone(arg3, 1200*time.Millisecond)
		return fakeOp, nil
	})
	fakeOp.WaitReturns(nil)
	fakeOp.GetReturns(lxdApi.Operation{
		Metadata: map[string]interface{}{
			"return": float64(8),
		},
	})
	exitCode, err := client.Exec("", nil, nil, nil, nil, false, false, 1, nil)
	assert.Error(t, err)
	assert.Exactly(t, ErrExecTimeout, err)
	assert.Equal(t, CodeExecTimeout, exitCode)
}