Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
"strings" |
| 9 | 9 |
"testing" |
| 10 | 10 |
|
| 11 |
+ "github.com/docker/docker/integration-cli/cli" |
|
| 11 | 12 |
"github.com/docker/docker/integration-cli/cli/build" |
| 12 | 13 |
"gotest.tools/v3/assert" |
| 13 | 14 |
"gotest.tools/v3/assert/cmp" |
| ... | ... |
@@ -28,7 +29,7 @@ func (s *DockerCLIHistorySuite) OnTimeout(c *testing.T) {
|
| 28 | 28 |
// This is a heisen-test. Because the created timestamp of images and the behavior of |
| 29 | 29 |
// sort is not predictable it doesn't always fail. |
| 30 | 30 |
func (s *DockerCLIHistorySuite) TestBuildHistory(c *testing.T) {
|
| 31 |
- name := "testbuildhistory" |
|
| 31 |
+ const name = "testbuildhistory" |
|
| 32 | 32 |
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` |
| 33 | 33 |
LABEL label.A="A" |
| 34 | 34 |
LABEL label.B="B" |
| ... | ... |
@@ -57,7 +58,7 @@ LABEL label.X="X" |
| 57 | 57 |
LABEL label.Y="Y" |
| 58 | 58 |
LABEL label.Z="Z"`)) |
| 59 | 59 |
|
| 60 |
- out, _ := dockerCmd(c, "history", name) |
|
| 60 |
+ out := cli.DockerCmd(c, "history", name).Combined() |
|
| 61 | 61 |
actualValues := strings.Split(out, "\n")[1:27] |
| 62 | 62 |
expectedValues := [26]string{"Z", "Y", "X", "W", "V", "U", "T", "S", "R", "Q", "P", "O", "N", "M", "L", "K", "J", "I", "H", "G", "F", "E", "D", "C", "B", "A"}
|
| 63 | 63 |
|
| ... | ... |
@@ -69,7 +70,7 @@ LABEL label.Z="Z"`)) |
| 69 | 69 |
} |
| 70 | 70 |
|
| 71 | 71 |
func (s *DockerCLIHistorySuite) TestHistoryExistentImage(c *testing.T) {
|
| 72 |
- dockerCmd(c, "history", "busybox") |
|
| 72 |
+ cli.DockerCmd(c, "history", "busybox") |
|
| 73 | 73 |
} |
| 74 | 74 |
|
| 75 | 75 |
func (s *DockerCLIHistorySuite) TestHistoryNonExistentImage(c *testing.T) {
|
| ... | ... |
@@ -78,26 +79,24 @@ func (s *DockerCLIHistorySuite) TestHistoryNonExistentImage(c *testing.T) {
|
| 78 | 78 |
} |
| 79 | 79 |
|
| 80 | 80 |
func (s *DockerCLIHistorySuite) TestHistoryImageWithComment(c *testing.T) {
|
| 81 |
- name := "testhistoryimagewithcomment" |
|
| 81 |
+ const name = "testhistoryimagewithcomment" |
|
| 82 | 82 |
|
| 83 | 83 |
// make an image through docker commit <container id> [ -m messages ] |
| 84 |
+ cli.DockerCmd(c, "run", "--name", name, "busybox", "true") |
|
| 85 |
+ cli.DockerCmd(c, "wait", name) |
|
| 84 | 86 |
|
| 85 |
- dockerCmd(c, "run", "--name", name, "busybox", "true") |
|
| 86 |
- dockerCmd(c, "wait", name) |
|
| 87 |
- |
|
| 88 |
- comment := "This_is_a_comment" |
|
| 89 |
- dockerCmd(c, "commit", "-m="+comment, name, name) |
|
| 87 |
+ const comment = "This_is_a_comment" |
|
| 88 |
+ cli.DockerCmd(c, "commit", "-m="+comment, name, name) |
|
| 90 | 89 |
|
| 91 | 90 |
// test docker history <image id> to check comment messages |
| 92 |
- |
|
| 93 |
- out, _ := dockerCmd(c, "history", name) |
|
| 91 |
+ out := cli.DockerCmd(c, "history", name).Combined() |
|
| 94 | 92 |
outputTabs := strings.Fields(strings.Split(out, "\n")[1]) |
| 95 | 93 |
actualValue := outputTabs[len(outputTabs)-1] |
| 96 | 94 |
assert.Assert(c, strings.Contains(actualValue, comment)) |
| 97 | 95 |
} |
| 98 | 96 |
|
| 99 | 97 |
func (s *DockerCLIHistorySuite) TestHistoryHumanOptionFalse(c *testing.T) {
|
| 100 |
- out, _ := dockerCmd(c, "history", "--human=false", "busybox") |
|
| 98 |
+ out := cli.DockerCmd(c, "history", "--human=false", "busybox").Combined() |
|
| 101 | 99 |
lines := strings.Split(out, "\n") |
| 102 | 100 |
sizeColumnRegex, _ := regexp.Compile("SIZE +")
|
| 103 | 101 |
indices := sizeColumnRegex.FindStringIndex(lines[0]) |
| ... | ... |
@@ -115,7 +114,7 @@ func (s *DockerCLIHistorySuite) TestHistoryHumanOptionFalse(c *testing.T) {
|
| 115 | 115 |
} |
| 116 | 116 |
|
| 117 | 117 |
func (s *DockerCLIHistorySuite) TestHistoryHumanOptionTrue(c *testing.T) {
|
| 118 |
- out, _ := dockerCmd(c, "history", "--human=true", "busybox") |
|
| 118 |
+ out := cli.DockerCmd(c, "history", "--human=true", "busybox").Combined() |
|
| 119 | 119 |
lines := strings.Split(out, "\n") |
| 120 | 120 |
sizeColumnRegex, _ := regexp.Compile("SIZE +")
|
| 121 | 121 |
humanSizeRegexRaw := "\\d+.*B" // Matches human sizes like 10 MB, 3.2 KB, etc |