mirror of https://github.com/docker/cli.git
26 lines
637 B
Go
26 lines
637 B
Go
package container
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/docker/cli/e2e/internal/fixtures"
|
|
"gotest.tools/v3/icmd"
|
|
)
|
|
|
|
func TestAttachExitCode(t *testing.T) {
|
|
const exitCode = 21
|
|
result := icmd.RunCommand("docker", "run", "-d", "-i", "--rm", fixtures.AlpineImage, "sh", "-c", fmt.Sprintf("read; exit %d", exitCode))
|
|
result.Assert(t, icmd.Success)
|
|
|
|
containerID := strings.TrimSpace(result.Stdout())
|
|
|
|
result = icmd.RunCmd(icmd.Command("docker", "attach", containerID), withStdinNewline)
|
|
result.Assert(t, icmd.Expected{ExitCode: exitCode})
|
|
}
|
|
|
|
func withStdinNewline(cmd *icmd.Cmd) {
|
|
cmd.Stdin = strings.NewReader("\n")
|
|
}
|