Bump go-units

To include  https://github.com/docker/go-units/pull/23
Fixes a unit test that fails because of it.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester 2017-02-07 21:58:56 +01:00
parent 09e99ef1fc
commit cb89d658dc
No known key found for this signature in database
GPG Key ID: 083CC6FD6EB699A3
9 changed files with 45 additions and 45 deletions

View File

@ -54,8 +54,8 @@ func TestContainerPsContext(t *testing.T) {
{types.Container{Created: unix}, true, time.Unix(unix, 0).String(), createdAtHeader, ctx.CreatedAt},
{types.Container{Ports: []types.Port{{PrivatePort: 8080, PublicPort: 8080, Type: "tcp"}}}, true, "8080/tcp", portsHeader, ctx.Ports},
{types.Container{Status: "RUNNING"}, true, "RUNNING", statusHeader, ctx.Status},
{types.Container{SizeRw: 10}, true, "10 B", sizeHeader, ctx.Size},
{types.Container{SizeRw: 10, SizeRootFs: 20}, true, "10 B (virtual 20 B)", sizeHeader, ctx.Size},
{types.Container{SizeRw: 10}, true, "10B", sizeHeader, ctx.Size},
{types.Container{SizeRw: 10, SizeRootFs: 20}, true, "10B (virtual 20B)", sizeHeader, ctx.Size},
{types.Container{}, true, "", labelsHeader, ctx.Labels},
{types.Container{Labels: map[string]string{"cpu": "6", "storage": "ssd"}}, true, "cpu=6,storage=ssd", labelsHeader, ctx.Labels},
{types.Container{Created: unix}, true, "About a minute", runningForHeader, ctx.RunningFor},
@ -160,8 +160,8 @@ func TestContainerContextWrite(t *testing.T) {
{
Context{Format: NewContainerFormat("table", false, true)},
`CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE
containerID1 ubuntu "" 24 hours ago foobar_baz 0 B
containerID2 ubuntu "" 24 hours ago foobar_bar 0 B
containerID1 ubuntu "" 24 hours ago foobar_baz 0B
containerID2 ubuntu "" 24 hours ago foobar_bar 0B
`,
},
{
@ -220,7 +220,7 @@ status:
names: foobar_baz
labels:
ports:
size: 0 B
size: 0B
container_id: containerID2
image: ubuntu
@ -230,7 +230,7 @@ status:
names: foobar_bar
labels:
ports:
size: 0 B
size: 0B
`, expectedTime, expectedTime),
},
@ -333,8 +333,8 @@ func TestContainerContextWriteJSON(t *testing.T) {
}
expectedCreated := time.Unix(unix, 0).String()
expectedJSONs := []map[string]interface{}{
{"Command": "\"\"", "CreatedAt": expectedCreated, "ID": "containerID1", "Image": "ubuntu", "Labels": "", "LocalVolumes": "0", "Mounts": "", "Names": "foobar_baz", "Networks": "", "Ports": "", "RunningFor": "About a minute", "Size": "0 B", "Status": ""},
{"Command": "\"\"", "CreatedAt": expectedCreated, "ID": "containerID2", "Image": "ubuntu", "Labels": "", "LocalVolumes": "0", "Mounts": "", "Names": "foobar_bar", "Networks": "", "Ports": "", "RunningFor": "About a minute", "Size": "0 B", "Status": ""},
{"Command": "\"\"", "CreatedAt": expectedCreated, "ID": "containerID1", "Image": "ubuntu", "Labels": "", "LocalVolumes": "0", "Mounts": "", "Names": "foobar_baz", "Networks": "", "Ports": "", "RunningFor": "About a minute", "Size": "0B", "Status": ""},
{"Command": "\"\"", "CreatedAt": expectedCreated, "ID": "containerID2", "Image": "ubuntu", "Labels": "", "LocalVolumes": "0", "Mounts": "", "Names": "foobar_bar", "Networks": "", "Ports": "", "RunningFor": "About a minute", "Size": "0B", "Status": ""},
}
out := bytes.NewBufferString("")
err := ContainerWrite(Context{Format: "{{json .}}", Output: out}, containers)

View File

@ -34,7 +34,7 @@ func TestImageContext(t *testing.T) {
{imageContext{
i: types.ImageSummary{Size: 10, VirtualSize: 10},
trunc: true,
}, "10 B", sizeHeader, ctx.Size},
}, "10B", sizeHeader, ctx.Size},
{imageContext{
i: types.ImageSummary{Created: unix},
trunc: true,
@ -109,9 +109,9 @@ func TestImageContextWrite(t *testing.T) {
},
},
`REPOSITORY TAG IMAGE ID CREATED SIZE
image tag1 imageID1 24 hours ago 0 B
image tag2 imageID2 24 hours ago 0 B
<none> <none> imageID3 24 hours ago 0 B
image tag1 imageID1 24 hours ago 0B
image tag2 imageID2 24 hours ago 0B
<none> <none> imageID3 24 hours ago 0B
`,
},
{
@ -159,9 +159,9 @@ image <none>
Digest: true,
},
`REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
image tag1 sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf imageID1 24 hours ago 0 B
image tag2 <none> imageID2 24 hours ago 0 B
<none> <none> <none> imageID3 24 hours ago 0 B
image tag1 sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf imageID1 24 hours ago 0B
image tag2 <none> imageID2 24 hours ago 0B
<none> <none> <none> imageID3 24 hours ago 0B
`,
},
{
@ -184,19 +184,19 @@ image tag2 <none>
tag: tag1
image_id: imageID1
created_at: %s
virtual_size: 0 B
virtual_size: 0B
repository: image
tag: tag2
image_id: imageID2
created_at: %s
virtual_size: 0 B
virtual_size: 0B
repository: <none>
tag: <none>
image_id: imageID3
created_at: %s
virtual_size: 0 B
virtual_size: 0B
`, expectedTime, expectedTime, expectedTime),
},
@ -212,21 +212,21 @@ tag: tag1
digest: sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
image_id: imageID1
created_at: %s
virtual_size: 0 B
virtual_size: 0B
repository: image
tag: tag2
digest: <none>
image_id: imageID2
created_at: %s
virtual_size: 0 B
virtual_size: 0B
repository: <none>
tag: <none>
digest: <none>
image_id: imageID3
created_at: %s
virtual_size: 0 B
virtual_size: 0B
`, expectedTime, expectedTime, expectedTime),
},

View File

@ -22,16 +22,16 @@ func TestContainerStatsContext(t *testing.T) {
{StatsEntry{Container: containerID}, "", containerID, containerHeader, ctx.Container},
{StatsEntry{CPUPercentage: 5.5}, "", "5.50%", cpuPercHeader, ctx.CPUPerc},
{StatsEntry{CPUPercentage: 5.5, IsInvalid: true}, "", "--", cpuPercHeader, ctx.CPUPerc},
{StatsEntry{NetworkRx: 0.31, NetworkTx: 12.3}, "", "0.31 B / 12.3 B", netIOHeader, ctx.NetIO},
{StatsEntry{NetworkRx: 0.31, NetworkTx: 12.3}, "", "0.31B / 12.3B", netIOHeader, ctx.NetIO},
{StatsEntry{NetworkRx: 0.31, NetworkTx: 12.3, IsInvalid: true}, "", "--", netIOHeader, ctx.NetIO},
{StatsEntry{BlockRead: 0.1, BlockWrite: 2.3}, "", "0.1 B / 2.3 B", blockIOHeader, ctx.BlockIO},
{StatsEntry{BlockRead: 0.1, BlockWrite: 2.3}, "", "0.1B / 2.3B", blockIOHeader, ctx.BlockIO},
{StatsEntry{BlockRead: 0.1, BlockWrite: 2.3, IsInvalid: true}, "", "--", blockIOHeader, ctx.BlockIO},
{StatsEntry{MemoryPercentage: 10.2}, "", "10.20%", memPercHeader, ctx.MemPerc},
{StatsEntry{MemoryPercentage: 10.2, IsInvalid: true}, "", "--", memPercHeader, ctx.MemPerc},
{StatsEntry{MemoryPercentage: 10.2}, "windows", "--", memPercHeader, ctx.MemPerc},
{StatsEntry{Memory: 24, MemoryLimit: 30}, "", "24 B / 30 B", memUseHeader, ctx.MemUsage},
{StatsEntry{Memory: 24, MemoryLimit: 30}, "", "24B / 30B", memUseHeader, ctx.MemUsage},
{StatsEntry{Memory: 24, MemoryLimit: 30, IsInvalid: true}, "", "-- / --", memUseHeader, ctx.MemUsage},
{StatsEntry{Memory: 24, MemoryLimit: 30}, "windows", "24 B", winMemUseHeader, ctx.MemUsage},
{StatsEntry{Memory: 24, MemoryLimit: 30}, "windows", "24B", winMemUseHeader, ctx.MemUsage},
{StatsEntry{PidsCurrent: 10}, "", "10", pidsHeader, ctx.PIDs},
{StatsEntry{PidsCurrent: 10, IsInvalid: true}, "", "--", pidsHeader, ctx.PIDs},
{StatsEntry{PidsCurrent: 10}, "windows", "--", pidsHeader, ctx.PIDs},
@ -68,7 +68,7 @@ func TestContainerStatsContextWrite(t *testing.T) {
{
Context{Format: "table {{.MemUsage}}"},
`MEM USAGE / LIMIT
20 B / 20 B
20B / 20B
-- / --
`,
},
@ -128,7 +128,7 @@ func TestContainerStatsContextWriteWindows(t *testing.T) {
{
Context{Format: "table {{.MemUsage}}"},
`PRIV WORKING SET
20 B
20B
-- / --
`,
},

View File

@ -12,7 +12,7 @@ import (
func TestMemBytesString(t *testing.T) {
var mem opts.MemBytes = 1048576
assert.Equal(t, mem.String(), "1 MiB")
assert.Equal(t, mem.String(), "1MiB")
}
func TestMemBytesSetAndValue(t *testing.T) {

View File

@ -151,7 +151,7 @@ func (s *DockerSuite) TestPsListContainersSize(c *check.C) {
baseLines := strings.Split(strings.Trim(baseOut, "\n "), "\n")
baseSizeIndex := strings.Index(baseLines[0], "SIZE")
baseFoundsize := baseLines[1][baseSizeIndex:]
baseBytes, err := strconv.Atoi(strings.Split(baseFoundsize, " ")[0])
baseBytes, err := strconv.Atoi(strings.Split(baseFoundsize, "B")[0])
c.Assert(err, checker.IsNil)
name := "test_size"
@ -177,7 +177,7 @@ func (s *DockerSuite) TestPsListContainersSize(c *check.C) {
idIndex := strings.Index(lines[0], "CONTAINER ID")
foundID := lines[1][idIndex : idIndex+12]
c.Assert(foundID, checker.Equals, id[:12], check.Commentf("Expected id %s, got %s", id[:12], foundID))
expectedSize := fmt.Sprintf("%d B", (2 + baseBytes))
expectedSize := fmt.Sprintf("%dB", (2 + baseBytes))
foundSize := lines[1][sizeIndex:]
c.Assert(foundSize, checker.Contains, expectedSize, check.Commentf("Expected size %q, got %q", expectedSize, foundSize))
}

View File

@ -30,15 +30,15 @@ func TestProgress(t *testing.T) {
t.Fatalf("Expected empty string, got '%s'", jp.String())
}
expected := " 1 B"
expected := " 1B"
jp2 := JSONProgress{Current: 1}
if jp2.String() != expected {
t.Fatalf("Expected %q, got %q", expected, jp2.String())
}
expectedStart := "[==========> ] 20 B/100 B"
expectedStart := "[==========> ] 20B/100B"
if termsz != nil && termsz.Width <= 110 {
expectedStart = " 20 B/100 B"
expectedStart = " 20B/100B"
}
jp3 := JSONProgress{Current: 20, Total: 100, Start: time.Now().Unix()}
// Just look at the start of the string
@ -47,9 +47,9 @@ func TestProgress(t *testing.T) {
t.Fatalf("Expected to start with %q, got %q", expectedStart, jp3.String())
}
expected = "[=========================> ] 50 B/100 B"
expected = "[=========================> ] 50B/100B"
if termsz != nil && termsz.Width <= 110 {
expected = " 50 B/100 B"
expected = " 50B/100B"
}
jp4 := JSONProgress{Current: 50, Total: 100}
if jp4.String() != expected {
@ -57,9 +57,9 @@ func TestProgress(t *testing.T) {
}
// this number can't be negative gh#7136
expected = "[==================================================>] 50 B"
expected = "[==================================================>] 50B"
if termsz != nil && termsz.Width <= 110 {
expected = " 50 B"
expected = " 50B"
}
jp5 := JSONProgress{Current: 50, Total: 40}
if jp5.String() != expected {
@ -133,7 +133,7 @@ func TestJSONMessageDisplay(t *testing.T) {
Progress: &JSONProgress{Current: 1},
}: {
"",
fmt.Sprintf("%c[1K%c[K\rstatus 1 B\r", 27, 27),
fmt.Sprintf("%c[1K%c[K\rstatus 1B\r", 27, 27),
},
}
@ -216,7 +216,7 @@ func TestDisplayJSONMessagesStream(t *testing.T) {
// With progressDetail
"{ \"id\": \"ID\", \"status\": \"status\", \"progressDetail\": { \"Current\": 1} }": {
"", // progressbar is disabled in non-terminal
fmt.Sprintf("\n%c[%dA%c[1K%c[K\rID: status 1 B\r%c[%dB", 27, 1, 27, 27, 27, 1),
fmt.Sprintf("\n%c[%dA%c[1K%c[K\rID: status 1B\r%c[%dB", 27, 1, 27, 27, 27, 1),
},
}

View File

@ -87,15 +87,15 @@ func TestJSONFormatProgress(t *testing.T) {
}
// The progress will always be in the format of:
// [=========================> ] 15 B/30 B 404933h7m11s
// [=========================> ] 15B/30B 412910h51m30s
// The last entry '404933h7m11s' is the timeLeftBox.
// However, the timeLeftBox field may change as progress.String() depends on time.Now().
// Therefore, we have to strip the timeLeftBox from the strings to do the comparison.
// Compare the progress strings before the timeLeftBox
expectedProgress := "[=========================> ] 15 B/30 B"
expectedProgress := "[=========================> ] 15B/30B"
// if terminal column is <= 110, expectedProgressShort is expected.
expectedProgressShort := " 15 B/30 B"
expectedProgressShort := " 15B/30B"
if !(strings.HasPrefix(msg.ProgressMessage, expectedProgress) ||
strings.HasPrefix(msg.ProgressMessage, expectedProgressShort)) {
t.Fatalf("ProgressMessage without the timeLeftBox must be %s or %s, got: %s",

View File

@ -15,7 +15,7 @@ github.com/vdemeester/shakers 24d7f1d6a71aa5d9cbe7390e4afb66b7eef9e1b3
# forked golang.org/x/net package includes a patch for lazy loading trace templates
golang.org/x/net 2beffdc2e92c8a3027590f898fe88f69af48a3f8 https://github.com/tonistiigi/net.git
golang.org/x/sys 8f0908ab3b2457e2e15403d3697c9ef5cb4b57a9
github.com/docker/go-units e30f1e79f3cd72542f2026ceec18d3bd67ab859c
github.com/docker/go-units 9e638d38cf6977a37a8ea0078f3ee75a7cdb2dd1
github.com/docker/go-connections 4ccf312bf1d35e5dbda654e57a9be4c3f3cd0366
github.com/RackSec/srslog 456df3a81436d29ba874f3590eeeee25d666f8a5

View File

@ -58,7 +58,7 @@ func CustomSize(format string, size float64, base float64, _map []string) string
// instead of 4 digit precision used in units.HumanSize.
func HumanSizeWithPrecision(size float64, precision int) string {
size, unit := getSizeAndUnit(size, 1000.0, decimapAbbrs)
return fmt.Sprintf("%.*g %s", precision, size, unit)
return fmt.Sprintf("%.*g%s", precision, size, unit)
}
// HumanSize returns a human-readable approximation of a size
@ -70,7 +70,7 @@ func HumanSize(size float64) string {
// BytesSize returns a human-readable size in bytes, kibibytes,
// mebibytes, gibibytes, or tebibytes (eg. "44kiB", "17MiB").
func BytesSize(size float64) string {
return CustomSize("%.4g %s", size, 1024.0, binaryAbbrs)
return CustomSize("%.4g%s", size, 1024.0, binaryAbbrs)
}
// FromHumanSize returns an integer from a human-readable specification of a