diff --git a/dockertest.go b/dockertest.go index 159605d6..87c1e8b4 100644 --- a/dockertest.go +++ b/dockertest.go @@ -301,6 +301,7 @@ type RunOptions struct { PortBindings map[dc.Port][]dc.PortBinding Privileged bool User string + Tty bool } // BuildOptions is used to pass in optional parameters when building a container @@ -435,6 +436,7 @@ func (d *Pool) RunWithOptions(opts *RunOptions, hcOpts ...func(*dc.HostConfig)) Labels: opts.Labels, StopSignal: "SIGWINCH", // to support timeouts User: opts.User, + Tty: opts.Tty, }, HostConfig: &hostConfig, NetworkingConfig: &networkingConfig, diff --git a/dockertest_test.go b/dockertest_test.go index 1586d056..1b8b85d8 100644 --- a/dockertest_test.go +++ b/dockertest_test.go @@ -129,6 +129,25 @@ func TestContainerWithUser(t *testing.T) { require.Nil(t, pool.Purge(resource)) } +func TestContainerWithTty(t *testing.T) { + resource, err := pool.RunWithOptions( + &RunOptions{ + Name: "db", + Repository: "postgres", + Tag: "9.5", + Env: []string{"POSTGRES_PASSWORD=secret"}, + Tty: true, + }) + require.Nil(t, err) + assert.True(t, resource.Container.Config.Tty, "tty is false") + + res, err := pool.Client.InspectContainer(resource.Container.ID) + require.Nil(t, err) + assert.True(t, res.Config.Tty) + + require.Nil(t, pool.Purge(resource)) +} + func TestContainerWithPortBinding(t *testing.T) { resource, err := pool.RunWithOptions( &RunOptions{ diff --git a/go.sum b/go.sum index 8a94b0c9..e1d43bbe 100644 --- a/go.sum +++ b/go.sum @@ -8,8 +8,7 @@ github.com/cenkalti/backoff/v4 v4.1.0 h1:c8LkOFQTzuO0WBM/ae5HdGQuZPfPxp7lqBRwQRm github.com/cenkalti/backoff/v4 v4.1.0/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw= github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= -github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -26,8 +25,6 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3 github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/lib/pq v0.0.0-20180327071824-d34b9ff171c2 h1:hRGSmZu7j271trc9sneMrpOW7GN5ngLm8YUZIPzf394= github.com/lib/pq v0.0.0-20180327071824-d34b9ff171c2/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/moby/term v0.0.0-20200915141129-7f0af18e79f2 h1:SPoLlS9qUUnXcIY4pvA4CTwYjk0Is5f4UPEkeESr53k= -github.com/moby/term v0.0.0-20200915141129-7f0af18e79f2/go.mod h1:TjQg8pa4iejrUrjiz0MCtMV38jdMNW4doKSiBrEvCQQ= github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 h1:rzf0wL0CHVc8CEsgyygG0Mn9CNCCPZqOPaz8RiiHYQk= github.com/moby/term v0.0.0-20201216013528-df9cb8a40635/go.mod h1:FBS0z0QWA44HXygs7VXDUOGoN/1TV3RuWkLO04am3wc= github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ=