MCPcopy Create free account
hub / github.com/docker/cli / TestValidateLabel

Function TestValidateLabel

opts/opts_test.go:247–347  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

245}
246
247func TestValidateLabel(t *testing.T) {
248 tests := []struct {
249 name string
250 value string
251 expectedErr string
252 }{
253 {
254 name: "empty",
255 expectedErr: `invalid label '': empty name`,
256 },
257 {
258 name: "whitespace only ",
259 value: " ",
260 expectedErr: `invalid label ' ': empty name`,
261 },
262 {
263 name: "whitespace around equal-sign",
264 value: " = ",
265 expectedErr: `invalid label ' = ': empty name`,
266 },
267 {
268 name: "leading whitespace",
269 value: " label=value",
270 },
271 {
272 name: "whitespaces in key without value",
273 value: "this is a label without value",
274 expectedErr: `label 'this is a label without value' contains whitespaces`,
275 },
276 {
277 name: "whitespaces in key",
278 value: "this is a label=value",
279 expectedErr: `label 'this is a label' contains whitespaces`,
280 },
281 {
282 name: "whitespaces in value",
283 value: "label=a value that has whitespace",
284 },
285 {
286 name: "trailing whitespace in value",
287 value: "label=value ",
288 },
289 {
290 name: "leading whitespace in value",
291 value: "label= value",
292 },
293 {
294 name: "no value",
295 value: "label",
296 },
297 {
298 name: "no key",
299 value: "=label",
300 expectedErr: `invalid label '=label': empty name`,
301 },
302 {
303 name: "empty value",
304 value: "label=",

Callers

nothing calls this directly

Calls 2

ValidateLabelFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…