github.com/rumpl/bof@v23.0.0-rc.2+incompatible/integration/container/exec_linux_test.go (about)

     1  package container // import "github.com/docker/docker/integration/container"
     2  
     3  import (
     4  	"context"
     5  	"strings"
     6  	"testing"
     7  
     8  	"github.com/docker/docker/api/types"
     9  	"github.com/docker/docker/api/types/versions"
    10  	"github.com/docker/docker/integration/internal/container"
    11  	"gotest.tools/v3/assert"
    12  	"gotest.tools/v3/skip"
    13  )
    14  
    15  func TestExecConsoleSize(t *testing.T) {
    16  	skip.If(t, testEnv.DaemonInfo.OSType != "linux")
    17  	skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.42"), "skip test from new feature")
    18  
    19  	defer setupTest(t)()
    20  	client := testEnv.APIClient()
    21  	ctx := context.Background()
    22  
    23  	cID := container.Run(ctx, t, client, container.WithImage("busybox"))
    24  
    25  	result, err := container.Exec(ctx, client, cID, []string{"stty", "size"},
    26  		func(ec *types.ExecConfig) {
    27  			ec.Tty = true
    28  			ec.ConsoleSize = &[2]uint{57, 123}
    29  		},
    30  	)
    31  
    32  	assert.NilError(t, err)
    33  	assert.Equal(t, strings.TrimSpace(result.Stdout()), "57 123")
    34  }