MCPcopy Index your code
hub / github.com/docker/cli / TestParseNetworkConfig

Function TestParseNetworkConfig

cli/command/container/opts_test.go:579–762  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

577}
578
579func TestParseNetworkConfig(t *testing.T) {
580 tests := []struct {
581 name string
582 flags []string
583 expected map[string]*networktypes.EndpointSettings
584 expectedHostCfg container.HostConfig
585 expectedErr string
586 }{
587 {
588 name: "single-network-legacy",
589 flags: []string{"--network", "net1"},
590 expected: map[string]*networktypes.EndpointSettings{},
591 expectedHostCfg: container.HostConfig{NetworkMode: "net1"},
592 },
593 {
594 name: "single-network-advanced",
595 flags: []string{"--network", "name=net1"},
596 expected: map[string]*networktypes.EndpointSettings{},
597 expectedHostCfg: container.HostConfig{NetworkMode: "net1"},
598 },
599 {
600 name: "single-network-legacy-with-options",
601 flags: []string{
602 "--ip", "172.20.88.22",
603 "--ip6", "2001:db8::8822",
604 "--link", "foo:bar",
605 "--link", "bar:baz",
606 "--link-local-ip", "169.254.2.2",
607 "--link-local-ip", "fe80::169:254:2:2",
608 "--network", "name=net1",
609 "--network-alias", "web1",
610 "--network-alias", "web2",
611 },
612 expected: map[string]*networktypes.EndpointSettings{
613 "net1": {
614 IPAMConfig: &networktypes.EndpointIPAMConfig{
615 IPv4Address: netip.MustParseAddr("172.20.88.22"),
616 IPv6Address: netip.MustParseAddr("2001:db8::8822"),
617 LinkLocalIPs: []netip.Addr{netip.MustParseAddr("169.254.2.2"), netip.MustParseAddr("fe80::169:254:2:2")},
618 },
619 Links: []string{"foo:bar", "bar:baz"},
620 Aliases: []string{"web1", "web2"},
621 },
622 },
623 expectedHostCfg: container.HostConfig{NetworkMode: "net1"},
624 },
625 {
626 name: "multiple-network-advanced-mixed",
627 flags: []string{
628 "--ip", "172.20.88.22",
629 "--ip6", "2001:db8::8822",
630 "--link", "foo:bar",
631 "--link", "bar:baz",
632 "--link-local-ip", "169.254.2.2",
633 "--link-local-ip", "fe80::169:254:2:2",
634 "--network", "name=net1,driver-opt=field1=value1",
635 "--network-alias", "web1",
636 "--network-alias", "web2",

Callers

nothing calls this directly

Calls 3

mustParseMACFunction · 0.85
parseRunFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…