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

Function TestConvertToStandardNotation

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

Source from the content-addressed store, hash-verified

1129}
1130
1131func TestConvertToStandardNotation(t *testing.T) {
1132 valid := map[string][]string{
1133 "20:10/tcp": {"target=10,published=20"},
1134 "40:30": {"40:30"},
1135 "20:20 80:4444": {"20:20", "80:4444"},
1136 "1500:2500/tcp 1400:1300": {"target=2500,published=1500", "1400:1300"},
1137 "1500:200/tcp 90:80/tcp": {"published=1500,target=200", "target=80,published=90"},
1138 }
1139
1140 invalid := [][]string{
1141 {"published=1500,target:444"},
1142 {"published=1500,444"},
1143 {"published=1500,target,444"},
1144 }
1145
1146 for key, ports := range valid {
1147 convertedPorts, err := convertToStandardNotation(ports)
1148 if err != nil {
1149 assert.NilError(t, err)
1150 }
1151 assert.DeepEqual(t, strings.Split(key, " "), convertedPorts)
1152 }
1153
1154 for _, ports := range invalid {
1155 if _, err := convertToStandardNotation(ports); err == nil {
1156 t.Fatalf("ConvertToStandardNotation(`%q`) should have failed conversion", ports)
1157 }
1158 }
1159}

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…