mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
dc0c2340b8
integration-cli/docker_cli_pull_test.go:55:69: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_exec_test.go:46:64: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_service_health_test.go:86:65: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_images_test.go:128:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_swarm_node_test.go:79:69: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_health_test.go:51:57: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_health_test.go:159:73: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_swarm_unix_test.go:60:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_inspect_test.go:30:33: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_build_test.go:429:71: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_attach_unix_test.go:19:78: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_build_test.go:470:70: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_history_test.go:29:64: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_links_test.go:93:86: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_create_test.go:33:61: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_links_test.go:145:78: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_create_test.go:114:70: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_attach_test.go:226:153: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_by_digest_test.go:239:71: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_create_test.go:135:49: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_create_test.go:143:75: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_create_test.go:181:71: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_inspect_test.go:72:65: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_swarm_service_test.go:98:77: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_swarm_service_test.go:144:69: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_rmi_test.go:63:2: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_swarm_service_test.go:199:79: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_rmi_test.go:69:2: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_swarm_service_test.go:300:75: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_prune_unix_test.go:35:25: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_events_unix_test.go:393:60: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_events_unix_test.go:441:71: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_ps_test.go:33:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_ps_test.go:559:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_events_test.go:117:75: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_containers_test.go:547:74: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_api_containers_test.go:1054:84: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_containers_test.go:1076:87: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_containers_test.go:1232:72: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_api_containers_test.go:1801:21: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_network_unix_test.go:58:95: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_network_unix_test.go:750:75: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_network_unix_test.go:765:76: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_swarm_test.go:617:100: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_swarm_test.go:892:72: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_daemon_test.go:119:74: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_daemon_test.go:981:68: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_daemon_test.go:1951:87: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_run_test.go:83:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_run_test.go:357:72: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_build_test.go:89:83: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:114:83: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:183:80: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:290:71: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:314:65: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:331:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:366:76: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:403:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:648:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:708:72: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:938:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1018:72: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1097:2: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1182:62: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1244:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1524:69: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1546:80: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1716:70: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1730:65: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:2162:74: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:2270:71: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:2288:70: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3206:65: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3392:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3433:72: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3678:76: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3732:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3759:69: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3802:61: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3898:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:4107:9: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:4791:74: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:4821:73: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:4854:70: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:5341:74: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:5593:81: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_containers_test.go:2145:11: empty-lines: extra empty line at the start of a block (revive) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
132 lines
3.9 KiB
Go
132 lines
3.9 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
"strconv"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/docker/docker/integration-cli/cli/build"
|
|
"gotest.tools/v3/assert"
|
|
"gotest.tools/v3/assert/cmp"
|
|
)
|
|
|
|
type DockerCLIHistorySuite struct {
|
|
ds *DockerSuite
|
|
}
|
|
|
|
func (s *DockerCLIHistorySuite) TearDownTest(c *testing.T) {
|
|
s.ds.TearDownTest(c)
|
|
}
|
|
|
|
func (s *DockerCLIHistorySuite) OnTimeout(c *testing.T) {
|
|
s.ds.OnTimeout(c)
|
|
}
|
|
|
|
// This is a heisen-test. Because the created timestamp of images and the behavior of
|
|
// sort is not predictable it doesn't always fail.
|
|
func (s *DockerCLIHistorySuite) TestBuildHistory(c *testing.T) {
|
|
name := "testbuildhistory"
|
|
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+`
|
|
LABEL label.A="A"
|
|
LABEL label.B="B"
|
|
LABEL label.C="C"
|
|
LABEL label.D="D"
|
|
LABEL label.E="E"
|
|
LABEL label.F="F"
|
|
LABEL label.G="G"
|
|
LABEL label.H="H"
|
|
LABEL label.I="I"
|
|
LABEL label.J="J"
|
|
LABEL label.K="K"
|
|
LABEL label.L="L"
|
|
LABEL label.M="M"
|
|
LABEL label.N="N"
|
|
LABEL label.O="O"
|
|
LABEL label.P="P"
|
|
LABEL label.Q="Q"
|
|
LABEL label.R="R"
|
|
LABEL label.S="S"
|
|
LABEL label.T="T"
|
|
LABEL label.U="U"
|
|
LABEL label.V="V"
|
|
LABEL label.W="W"
|
|
LABEL label.X="X"
|
|
LABEL label.Y="Y"
|
|
LABEL label.Z="Z"`))
|
|
|
|
out, _ := dockerCmd(c, "history", name)
|
|
actualValues := strings.Split(out, "\n")[1:27]
|
|
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"}
|
|
|
|
for i := 0; i < 26; i++ {
|
|
echoValue := fmt.Sprintf("LABEL label.%s=%s", expectedValues[i], expectedValues[i])
|
|
actualValue := actualValues[i]
|
|
assert.Assert(c, strings.Contains(actualValue, echoValue))
|
|
}
|
|
}
|
|
|
|
func (s *DockerCLIHistorySuite) TestHistoryExistentImage(c *testing.T) {
|
|
dockerCmd(c, "history", "busybox")
|
|
}
|
|
|
|
func (s *DockerCLIHistorySuite) TestHistoryNonExistentImage(c *testing.T) {
|
|
_, _, err := dockerCmdWithError("history", "testHistoryNonExistentImage")
|
|
assert.Assert(c, err != nil, "history on a non-existent image should fail.")
|
|
}
|
|
|
|
func (s *DockerCLIHistorySuite) TestHistoryImageWithComment(c *testing.T) {
|
|
name := "testhistoryimagewithcomment"
|
|
|
|
// make an image through docker commit <container id> [ -m messages ]
|
|
|
|
dockerCmd(c, "run", "--name", name, "busybox", "true")
|
|
dockerCmd(c, "wait", name)
|
|
|
|
comment := "This_is_a_comment"
|
|
dockerCmd(c, "commit", "-m="+comment, name, name)
|
|
|
|
// test docker history <image id> to check comment messages
|
|
|
|
out, _ := dockerCmd(c, "history", name)
|
|
outputTabs := strings.Fields(strings.Split(out, "\n")[1])
|
|
actualValue := outputTabs[len(outputTabs)-1]
|
|
assert.Assert(c, strings.Contains(actualValue, comment))
|
|
}
|
|
|
|
func (s *DockerCLIHistorySuite) TestHistoryHumanOptionFalse(c *testing.T) {
|
|
out, _ := dockerCmd(c, "history", "--human=false", "busybox")
|
|
lines := strings.Split(out, "\n")
|
|
sizeColumnRegex, _ := regexp.Compile("SIZE +")
|
|
indices := sizeColumnRegex.FindStringIndex(lines[0])
|
|
startIndex := indices[0]
|
|
endIndex := indices[1]
|
|
for i := 1; i < len(lines)-1; i++ {
|
|
if endIndex > len(lines[i]) {
|
|
endIndex = len(lines[i])
|
|
}
|
|
sizeString := lines[i][startIndex:endIndex]
|
|
|
|
_, err := strconv.Atoi(strings.TrimSpace(sizeString))
|
|
assert.Assert(c, err == nil, "The size '%s' was not an Integer", sizeString)
|
|
}
|
|
}
|
|
|
|
func (s *DockerCLIHistorySuite) TestHistoryHumanOptionTrue(c *testing.T) {
|
|
out, _ := dockerCmd(c, "history", "--human=true", "busybox")
|
|
lines := strings.Split(out, "\n")
|
|
sizeColumnRegex, _ := regexp.Compile("SIZE +")
|
|
humanSizeRegexRaw := "\\d+.*B" // Matches human sizes like 10 MB, 3.2 KB, etc
|
|
indices := sizeColumnRegex.FindStringIndex(lines[0])
|
|
startIndex := indices[0]
|
|
endIndex := indices[1]
|
|
for i := 1; i < len(lines)-1; i++ {
|
|
if endIndex > len(lines[i]) {
|
|
endIndex = len(lines[i])
|
|
}
|
|
sizeString := lines[i][startIndex:endIndex]
|
|
assert.Assert(c, cmp.Regexp("^"+humanSizeRegexRaw+"$",
|
|
strings.TrimSpace(sizeString)), fmt.Sprintf("The size '%s' was not in human format", sizeString))
|
|
}
|
|
}
|