Browse code

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>

Vincent Demeester authored on 2017/02/08 05:58:56
Showing 9 changed files
... ...
@@ -54,8 +54,8 @@ func TestContainerPsContext(t *testing.T) {
54 54
 		{types.Container{Created: unix}, true, time.Unix(unix, 0).String(), createdAtHeader, ctx.CreatedAt},
55 55
 		{types.Container{Ports: []types.Port{{PrivatePort: 8080, PublicPort: 8080, Type: "tcp"}}}, true, "8080/tcp", portsHeader, ctx.Ports},
56 56
 		{types.Container{Status: "RUNNING"}, true, "RUNNING", statusHeader, ctx.Status},
57
-		{types.Container{SizeRw: 10}, true, "10 B", sizeHeader, ctx.Size},
58
-		{types.Container{SizeRw: 10, SizeRootFs: 20}, true, "10 B (virtual 20 B)", sizeHeader, ctx.Size},
57
+		{types.Container{SizeRw: 10}, true, "10B", sizeHeader, ctx.Size},
58
+		{types.Container{SizeRw: 10, SizeRootFs: 20}, true, "10B (virtual 20B)", sizeHeader, ctx.Size},
59 59
 		{types.Container{}, true, "", labelsHeader, ctx.Labels},
60 60
 		{types.Container{Labels: map[string]string{"cpu": "6", "storage": "ssd"}}, true, "cpu=6,storage=ssd", labelsHeader, ctx.Labels},
61 61
 		{types.Container{Created: unix}, true, "About a minute", runningForHeader, ctx.RunningFor},
... ...
@@ -160,8 +160,8 @@ func TestContainerContextWrite(t *testing.T) {
160 160
 		{
161 161
 			Context{Format: NewContainerFormat("table", false, true)},
162 162
 			`CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES               SIZE
163
-containerID1        ubuntu              ""                  24 hours ago                                                foobar_baz          0 B
164
-containerID2        ubuntu              ""                  24 hours ago                                                foobar_bar          0 B
163
+containerID1        ubuntu              ""                  24 hours ago                                                foobar_baz          0B
164
+containerID2        ubuntu              ""                  24 hours ago                                                foobar_bar          0B
165 165
 `,
166 166
 		},
167 167
 		{
... ...
@@ -220,7 +220,7 @@ status:
220 220
 names: foobar_baz
221 221
 labels:
222 222
 ports:
223
-size: 0 B
223
+size: 0B
224 224
 
225 225
 container_id: containerID2
226 226
 image: ubuntu
... ...
@@ -230,7 +230,7 @@ status:
230 230
 names: foobar_bar
231 231
 labels:
232 232
 ports:
233
-size: 0 B
233
+size: 0B
234 234
 
235 235
 `, expectedTime, expectedTime),
236 236
 		},
... ...
@@ -333,8 +333,8 @@ func TestContainerContextWriteJSON(t *testing.T) {
333 333
 	}
334 334
 	expectedCreated := time.Unix(unix, 0).String()
335 335
 	expectedJSONs := []map[string]interface{}{
336
-		{"Command": "\"\"", "CreatedAt": expectedCreated, "ID": "containerID1", "Image": "ubuntu", "Labels": "", "LocalVolumes": "0", "Mounts": "", "Names": "foobar_baz", "Networks": "", "Ports": "", "RunningFor": "About a minute", "Size": "0 B", "Status": ""},
337
-		{"Command": "\"\"", "CreatedAt": expectedCreated, "ID": "containerID2", "Image": "ubuntu", "Labels": "", "LocalVolumes": "0", "Mounts": "", "Names": "foobar_bar", "Networks": "", "Ports": "", "RunningFor": "About a minute", "Size": "0 B", "Status": ""},
336
+		{"Command": "\"\"", "CreatedAt": expectedCreated, "ID": "containerID1", "Image": "ubuntu", "Labels": "", "LocalVolumes": "0", "Mounts": "", "Names": "foobar_baz", "Networks": "", "Ports": "", "RunningFor": "About a minute", "Size": "0B", "Status": ""},
337
+		{"Command": "\"\"", "CreatedAt": expectedCreated, "ID": "containerID2", "Image": "ubuntu", "Labels": "", "LocalVolumes": "0", "Mounts": "", "Names": "foobar_bar", "Networks": "", "Ports": "", "RunningFor": "About a minute", "Size": "0B", "Status": ""},
338 338
 	}
339 339
 	out := bytes.NewBufferString("")
340 340
 	err := ContainerWrite(Context{Format: "{{json .}}", Output: out}, containers)
... ...
@@ -34,7 +34,7 @@ func TestImageContext(t *testing.T) {
34 34
 		{imageContext{
35 35
 			i:     types.ImageSummary{Size: 10, VirtualSize: 10},
36 36
 			trunc: true,
37
-		}, "10 B", sizeHeader, ctx.Size},
37
+		}, "10B", sizeHeader, ctx.Size},
38 38
 		{imageContext{
39 39
 			i:     types.ImageSummary{Created: unix},
40 40
 			trunc: true,
... ...
@@ -109,9 +109,9 @@ func TestImageContextWrite(t *testing.T) {
109 109
 				},
110 110
 			},
111 111
 			`REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
112
-image               tag1                imageID1            24 hours ago        0 B
113
-image               tag2                imageID2            24 hours ago        0 B
114
-<none>              <none>              imageID3            24 hours ago        0 B
112
+image               tag1                imageID1            24 hours ago        0B
113
+image               tag2                imageID2            24 hours ago        0B
114
+<none>              <none>              imageID3            24 hours ago        0B
115 115
 `,
116 116
 		},
117 117
 		{
... ...
@@ -159,9 +159,9 @@ image               <none>
159 159
 				Digest: true,
160 160
 			},
161 161
 			`REPOSITORY          TAG                 DIGEST                                                                    IMAGE ID            CREATED             SIZE
162
-image               tag1                sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf   imageID1            24 hours ago        0 B
163
-image               tag2                <none>                                                                    imageID2            24 hours ago        0 B
164
-<none>              <none>              <none>                                                                    imageID3            24 hours ago        0 B
162
+image               tag1                sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf   imageID1            24 hours ago        0B
163
+image               tag2                <none>                                                                    imageID2            24 hours ago        0B
164
+<none>              <none>              <none>                                                                    imageID3            24 hours ago        0B
165 165
 `,
166 166
 		},
167 167
 		{
... ...
@@ -184,19 +184,19 @@ image               tag2                <none>
184 184
 tag: tag1
185 185
 image_id: imageID1
186 186
 created_at: %s
187
-virtual_size: 0 B
187
+virtual_size: 0B
188 188
 
189 189
 repository: image
190 190
 tag: tag2
191 191
 image_id: imageID2
192 192
 created_at: %s
193
-virtual_size: 0 B
193
+virtual_size: 0B
194 194
 
195 195
 repository: <none>
196 196
 tag: <none>
197 197
 image_id: imageID3
198 198
 created_at: %s
199
-virtual_size: 0 B
199
+virtual_size: 0B
200 200
 
201 201
 `, expectedTime, expectedTime, expectedTime),
202 202
 		},
... ...
@@ -212,21 +212,21 @@ tag: tag1
212 212
 digest: sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
213 213
 image_id: imageID1
214 214
 created_at: %s
215
-virtual_size: 0 B
215
+virtual_size: 0B
216 216
 
217 217
 repository: image
218 218
 tag: tag2
219 219
 digest: <none>
220 220
 image_id: imageID2
221 221
 created_at: %s
222
-virtual_size: 0 B
222
+virtual_size: 0B
223 223
 
224 224
 repository: <none>
225 225
 tag: <none>
226 226
 digest: <none>
227 227
 image_id: imageID3
228 228
 created_at: %s
229
-virtual_size: 0 B
229
+virtual_size: 0B
230 230
 
231 231
 `, expectedTime, expectedTime, expectedTime),
232 232
 		},
... ...
@@ -22,16 +22,16 @@ func TestContainerStatsContext(t *testing.T) {
22 22
 		{StatsEntry{Container: containerID}, "", containerID, containerHeader, ctx.Container},
23 23
 		{StatsEntry{CPUPercentage: 5.5}, "", "5.50%", cpuPercHeader, ctx.CPUPerc},
24 24
 		{StatsEntry{CPUPercentage: 5.5, IsInvalid: true}, "", "--", cpuPercHeader, ctx.CPUPerc},
25
-		{StatsEntry{NetworkRx: 0.31, NetworkTx: 12.3}, "", "0.31 B / 12.3 B", netIOHeader, ctx.NetIO},
25
+		{StatsEntry{NetworkRx: 0.31, NetworkTx: 12.3}, "", "0.31B / 12.3B", netIOHeader, ctx.NetIO},
26 26
 		{StatsEntry{NetworkRx: 0.31, NetworkTx: 12.3, IsInvalid: true}, "", "--", netIOHeader, ctx.NetIO},
27
-		{StatsEntry{BlockRead: 0.1, BlockWrite: 2.3}, "", "0.1 B / 2.3 B", blockIOHeader, ctx.BlockIO},
27
+		{StatsEntry{BlockRead: 0.1, BlockWrite: 2.3}, "", "0.1B / 2.3B", blockIOHeader, ctx.BlockIO},
28 28
 		{StatsEntry{BlockRead: 0.1, BlockWrite: 2.3, IsInvalid: true}, "", "--", blockIOHeader, ctx.BlockIO},
29 29
 		{StatsEntry{MemoryPercentage: 10.2}, "", "10.20%", memPercHeader, ctx.MemPerc},
30 30
 		{StatsEntry{MemoryPercentage: 10.2, IsInvalid: true}, "", "--", memPercHeader, ctx.MemPerc},
31 31
 		{StatsEntry{MemoryPercentage: 10.2}, "windows", "--", memPercHeader, ctx.MemPerc},
32
-		{StatsEntry{Memory: 24, MemoryLimit: 30}, "", "24 B / 30 B", memUseHeader, ctx.MemUsage},
32
+		{StatsEntry{Memory: 24, MemoryLimit: 30}, "", "24B / 30B", memUseHeader, ctx.MemUsage},
33 33
 		{StatsEntry{Memory: 24, MemoryLimit: 30, IsInvalid: true}, "", "-- / --", memUseHeader, ctx.MemUsage},
34
-		{StatsEntry{Memory: 24, MemoryLimit: 30}, "windows", "24 B", winMemUseHeader, ctx.MemUsage},
34
+		{StatsEntry{Memory: 24, MemoryLimit: 30}, "windows", "24B", winMemUseHeader, ctx.MemUsage},
35 35
 		{StatsEntry{PidsCurrent: 10}, "", "10", pidsHeader, ctx.PIDs},
36 36
 		{StatsEntry{PidsCurrent: 10, IsInvalid: true}, "", "--", pidsHeader, ctx.PIDs},
37 37
 		{StatsEntry{PidsCurrent: 10}, "windows", "--", pidsHeader, ctx.PIDs},
... ...
@@ -68,7 +68,7 @@ func TestContainerStatsContextWrite(t *testing.T) {
68 68
 		{
69 69
 			Context{Format: "table {{.MemUsage}}"},
70 70
 			`MEM USAGE / LIMIT
71
-20 B / 20 B
71
+20B / 20B
72 72
 -- / --
73 73
 `,
74 74
 		},
... ...
@@ -128,7 +128,7 @@ func TestContainerStatsContextWriteWindows(t *testing.T) {
128 128
 		{
129 129
 			Context{Format: "table {{.MemUsage}}"},
130 130
 			`PRIV WORKING SET
131
-20 B
131
+20B
132 132
 -- / --
133 133
 `,
134 134
 		},
... ...
@@ -12,7 +12,7 @@ import (
12 12
 
13 13
 func TestMemBytesString(t *testing.T) {
14 14
 	var mem opts.MemBytes = 1048576
15
-	assert.Equal(t, mem.String(), "1 MiB")
15
+	assert.Equal(t, mem.String(), "1MiB")
16 16
 }
17 17
 
18 18
 func TestMemBytesSetAndValue(t *testing.T) {
... ...
@@ -151,7 +151,7 @@ func (s *DockerSuite) TestPsListContainersSize(c *check.C) {
151 151
 	baseLines := strings.Split(strings.Trim(baseOut, "\n "), "\n")
152 152
 	baseSizeIndex := strings.Index(baseLines[0], "SIZE")
153 153
 	baseFoundsize := baseLines[1][baseSizeIndex:]
154
-	baseBytes, err := strconv.Atoi(strings.Split(baseFoundsize, " ")[0])
154
+	baseBytes, err := strconv.Atoi(strings.Split(baseFoundsize, "B")[0])
155 155
 	c.Assert(err, checker.IsNil)
156 156
 
157 157
 	name := "test_size"
... ...
@@ -177,7 +177,7 @@ func (s *DockerSuite) TestPsListContainersSize(c *check.C) {
177 177
 	idIndex := strings.Index(lines[0], "CONTAINER ID")
178 178
 	foundID := lines[1][idIndex : idIndex+12]
179 179
 	c.Assert(foundID, checker.Equals, id[:12], check.Commentf("Expected id %s, got %s", id[:12], foundID))
180
-	expectedSize := fmt.Sprintf("%d B", (2 + baseBytes))
180
+	expectedSize := fmt.Sprintf("%dB", (2 + baseBytes))
181 181
 	foundSize := lines[1][sizeIndex:]
182 182
 	c.Assert(foundSize, checker.Contains, expectedSize, check.Commentf("Expected size %q, got %q", expectedSize, foundSize))
183 183
 }
... ...
@@ -30,15 +30,15 @@ func TestProgress(t *testing.T) {
30 30
 		t.Fatalf("Expected empty string, got '%s'", jp.String())
31 31
 	}
32 32
 
33
-	expected := "     1 B"
33
+	expected := "      1B"
34 34
 	jp2 := JSONProgress{Current: 1}
35 35
 	if jp2.String() != expected {
36 36
 		t.Fatalf("Expected %q, got %q", expected, jp2.String())
37 37
 	}
38 38
 
39
-	expectedStart := "[==========>                                        ]     20 B/100 B"
39
+	expectedStart := "[==========>                                        ]      20B/100B"
40 40
 	if termsz != nil && termsz.Width <= 110 {
41
-		expectedStart = "    20 B/100 B"
41
+		expectedStart = "    20B/100B"
42 42
 	}
43 43
 	jp3 := JSONProgress{Current: 20, Total: 100, Start: time.Now().Unix()}
44 44
 	// Just look at the start of the string
... ...
@@ -47,9 +47,9 @@ func TestProgress(t *testing.T) {
47 47
 		t.Fatalf("Expected to start with %q, got %q", expectedStart, jp3.String())
48 48
 	}
49 49
 
50
-	expected = "[=========================>                         ]     50 B/100 B"
50
+	expected = "[=========================>                         ]      50B/100B"
51 51
 	if termsz != nil && termsz.Width <= 110 {
52
-		expected = "    50 B/100 B"
52
+		expected = "    50B/100B"
53 53
 	}
54 54
 	jp4 := JSONProgress{Current: 50, Total: 100}
55 55
 	if jp4.String() != expected {
... ...
@@ -57,9 +57,9 @@ func TestProgress(t *testing.T) {
57 57
 	}
58 58
 
59 59
 	// this number can't be negative gh#7136
60
-	expected = "[==================================================>]     50 B"
60
+	expected = "[==================================================>]      50B"
61 61
 	if termsz != nil && termsz.Width <= 110 {
62
-		expected = "    50 B"
62
+		expected = "    50B"
63 63
 	}
64 64
 	jp5 := JSONProgress{Current: 50, Total: 40}
65 65
 	if jp5.String() != expected {
... ...
@@ -133,7 +133,7 @@ func TestJSONMessageDisplay(t *testing.T) {
133 133
 			Progress: &JSONProgress{Current: 1},
134 134
 		}: {
135 135
 			"",
136
-			fmt.Sprintf("%c[1K%c[K\rstatus      1 B\r", 27, 27),
136
+			fmt.Sprintf("%c[1K%c[K\rstatus       1B\r", 27, 27),
137 137
 		},
138 138
 	}
139 139
 
... ...
@@ -216,7 +216,7 @@ func TestDisplayJSONMessagesStream(t *testing.T) {
216 216
 		// With progressDetail
217 217
 		"{ \"id\": \"ID\", \"status\": \"status\", \"progressDetail\": { \"Current\": 1} }": {
218 218
 			"", // progressbar is disabled in non-terminal
219
-			fmt.Sprintf("\n%c[%dA%c[1K%c[K\rID: status      1 B\r%c[%dB", 27, 1, 27, 27, 27, 1),
219
+			fmt.Sprintf("\n%c[%dA%c[1K%c[K\rID: status       1B\r%c[%dB", 27, 1, 27, 27, 27, 1),
220 220
 		},
221 221
 	}
222 222
 
... ...
@@ -87,15 +87,15 @@ func TestJSONFormatProgress(t *testing.T) {
87 87
 	}
88 88
 
89 89
 	// The progress will always be in the format of:
90
-	// [=========================>                         ]     15 B/30 B 404933h7m11s
90
+	// [=========================>                         ]      15B/30B 412910h51m30s
91 91
 	// The last entry '404933h7m11s' is the timeLeftBox.
92 92
 	// However, the timeLeftBox field may change as progress.String() depends on time.Now().
93 93
 	// Therefore, we have to strip the timeLeftBox from the strings to do the comparison.
94 94
 
95 95
 	// Compare the progress strings before the timeLeftBox
96
-	expectedProgress := "[=========================>                         ]     15 B/30 B"
96
+	expectedProgress := "[=========================>                         ]      15B/30B"
97 97
 	// if terminal column is <= 110, expectedProgressShort is expected.
98
-	expectedProgressShort := "    15 B/30 B"
98
+	expectedProgressShort := "      15B/30B"
99 99
 	if !(strings.HasPrefix(msg.ProgressMessage, expectedProgress) ||
100 100
 		strings.HasPrefix(msg.ProgressMessage, expectedProgressShort)) {
101 101
 		t.Fatalf("ProgressMessage without the timeLeftBox must be %s or %s, got: %s",
... ...
@@ -15,7 +15,7 @@ github.com/vdemeester/shakers 24d7f1d6a71aa5d9cbe7390e4afb66b7eef9e1b3
15 15
 # forked golang.org/x/net package includes a patch for lazy loading trace templates
16 16
 golang.org/x/net 2beffdc2e92c8a3027590f898fe88f69af48a3f8 https://github.com/tonistiigi/net.git
17 17
 golang.org/x/sys 8f0908ab3b2457e2e15403d3697c9ef5cb4b57a9
18
-github.com/docker/go-units e30f1e79f3cd72542f2026ceec18d3bd67ab859c
18
+github.com/docker/go-units 9e638d38cf6977a37a8ea0078f3ee75a7cdb2dd1
19 19
 github.com/docker/go-connections 4ccf312bf1d35e5dbda654e57a9be4c3f3cd0366
20 20
 
21 21
 github.com/RackSec/srslog 456df3a81436d29ba874f3590eeeee25d666f8a5
... ...
@@ -58,7 +58,7 @@ func CustomSize(format string, size float64, base float64, _map []string) string
58 58
 // instead of 4 digit precision used in units.HumanSize.
59 59
 func HumanSizeWithPrecision(size float64, precision int) string {
60 60
 	size, unit := getSizeAndUnit(size, 1000.0, decimapAbbrs)
61
-	return fmt.Sprintf("%.*g %s", precision, size, unit)
61
+	return fmt.Sprintf("%.*g%s", precision, size, unit)
62 62
 }
63 63
 
64 64
 // HumanSize returns a human-readable approximation of a size
... ...
@@ -70,7 +70,7 @@ func HumanSize(size float64) string {
70 70
 // BytesSize returns a human-readable size in bytes, kibibytes,
71 71
 // mebibytes, gibibytes, or tebibytes (eg. "44kiB", "17MiB").
72 72
 func BytesSize(size float64) string {
73
-	return CustomSize("%.4g %s", size, 1024.0, binaryAbbrs)
73
+	return CustomSize("%.4g%s", size, 1024.0, binaryAbbrs)
74 74
 }
75 75
 
76 76
 // FromHumanSize returns an integer from a human-readable specification of a