(t *testing.T, ctx context.Context, containerName string, cmd []string)
| 980 | } |
| 981 | |
| 982 | func execInContainer(t *testing.T, ctx context.Context, containerName string, cmd []string) { |
| 983 | t.Helper() |
| 984 | |
| 985 | c, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) |
| 986 | require.NoError(t, err) |
| 987 | defer c.Close() |
| 988 | |
| 989 | execResp, err := c.ContainerExecCreate(ctx, containerName, container.ExecOptions{ |
| 990 | Cmd: cmd, |
| 991 | AttachStdout: true, |
| 992 | AttachStderr: true, |
| 993 | }) |
| 994 | require.NoError(t, err) |
| 995 | |
| 996 | resp, err := c.ContainerExecAttach(ctx, execResp.ID, container.ExecStartOptions{}) |
| 997 | require.NoError(t, err) |
| 998 | defer resp.Close() |
| 999 | |
| 1000 | _, err = io.Copy(io.Discard, resp.Reader) |
| 1001 | require.NoError(t, err) |
| 1002 | |
| 1003 | inspect, err := c.ContainerExecInspect(ctx, execResp.ID) |
| 1004 | require.NoError(t, err) |
| 1005 | require.Equal(t, 0, inspect.ExitCode, "exec command failed") |
| 1006 | } |
| 1007 | |
| 1008 | func copyHookToContainer(t *testing.T, ctx context.Context, containerName, hookName string, script []byte) { |
| 1009 | t.Helper() |
no test coverage detected
searching dependent graphs…