@@ -14,10 +14,8 @@ import (
14
14
"time"
15
15
16
16
"github.com/coder/coder/v2/codersdk"
17
- "github.com/docker/docker/api/types"
18
17
"github.com/docker/docker/api/types/container"
19
18
"github.com/docker/docker/client"
20
- "github.com/docker/docker/pkg/stdcopy"
21
19
"github.com/docker/go-connections/nat"
22
20
"github.com/stretchr/testify/assert"
23
21
"github.com/stretchr/testify/require"
@@ -27,7 +25,7 @@ import (
27
25
// For each directory containing a `main.tf` under `/integration`, performs the following:
28
26
// - Creates a temporary Coder instance running in Docker
29
27
// - Runs the `main.tf` specified in the given test directory against the Coder deployment
30
- // - Asserts the state of the deployment via `codersdk`
28
+ // - Asserts the state of the deployment via `codersdk`.
31
29
func TestIntegration (t * testing.T ) {
32
30
if os .Getenv ("TF_ACC" ) == "1" {
33
31
t .Skip ("Skipping integration tests during tf acceptance tests" )
@@ -190,34 +188,6 @@ func startCoder(ctx context.Context, t *testing.T, name string) *codersdk.Client
190
188
return client
191
189
}
192
190
193
- // execContainer executes the given command in the given container and returns
194
- // the output and the exit code of the command.
195
- func execContainer (ctx context.Context , t testing.TB , containerID , command string ) (string , int ) {
196
- t .Helper ()
197
- t .Logf ("exec container cmd: %q" , command )
198
- cli , err := client .NewClientWithOpts (client .FromEnv , client .WithAPIVersionNegotiation ())
199
- require .NoError (t , err , "connect to docker" )
200
- defer cli .Close ()
201
- execConfig := types.ExecConfig {
202
- AttachStdout : true ,
203
- AttachStderr : true ,
204
- Cmd : []string {"/bin/sh" , "-c" , command },
205
- }
206
- ex , err := cli .ContainerExecCreate (ctx , containerID , execConfig )
207
- require .NoError (t , err , "create container exec" )
208
- resp , err := cli .ContainerExecAttach (ctx , ex .ID , types.ExecStartCheck {})
209
- require .NoError (t , err , "attach to container exec" )
210
- defer resp .Close ()
211
- var buf bytes.Buffer
212
- _ , err = stdcopy .StdCopy (& buf , & buf , resp .Reader )
213
- require .NoError (t , err , "read stdout" )
214
- out := buf .String ()
215
- t .Log ("exec container output:\n " + out )
216
- execResp , err := cli .ContainerExecInspect (ctx , ex .ID )
217
- require .NoError (t , err , "get exec exit code" )
218
- return out , execResp .ExitCode
219
- }
220
-
221
191
// randomPort is a helper function to find a free random port.
222
192
// Note that the OS may reallocate the port very quickly, so
223
193
// this is not _guaranteed_.
0 commit comments