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

Function TestNonStringKeys

cli/compose/loader/loader_test.go:334–377  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

332}
333
334func TestNonStringKeys(t *testing.T) {
335 // FIXME(thaJeztah): opkg.in/yaml.v3, which always unmarshals to a map[string]any, so we cannot produce a customized error for invalid types.
336 t.Skip("not supported by go.yaml.in/yaml/v3, which always unmarshals to a map[string]any")
337 _, err := loadYAML(`
338version: "3"
339123:
340 foo:
341 image: busybox
342`)
343 assert.Check(t, is.ErrorContains(err, "non-string key at top level: 123"))
344
345 _, err = loadYAML(`
346version: "3"
347services:
348 foo:
349 image: busybox
350 123:
351 image: busybox
352`)
353 assert.Check(t, is.ErrorContains(err, "non-string key in services: 123"))
354
355 _, err = loadYAML(`
356version: "3"
357services:
358 foo:
359 image: busybox
360networks:
361 default:
362 ipam:
363 config:
364 - 123: oh dear
365`)
366 assert.Check(t, is.ErrorContains(err, "non-string key in networks.default.ipam.config[0]: 123"))
367
368 _, err = loadYAML(`
369version: "3"
370services:
371 dict-env:
372 image: busybox
373 environment:
374 1: FOO
375`)
376 assert.Check(t, is.ErrorContains(err, "non-string key in services.dict-env.environment: 1"))
377}
378
379func TestSupportedVersion(t *testing.T) {
380 _, err := loadYAML(`

Callers

nothing calls this directly

Calls 1

loadYAMLFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…