MCPcopy Create free account
hub / github.com/containerd/nerdctl / TestFormatPorts

Function TestFormatPorts

pkg/formatter/formatter_test.go:94–195  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

92}
93
94func TestFormatPorts(t *testing.T) {
95 t.Parallel()
96
97 tests := []struct {
98 name string
99 input []cni.PortMapping
100 expected string
101 }{
102 {
103 name: "a single tcp port on localhost",
104 input: []cni.PortMapping{
105 {
106 HostPort: 3000,
107 ContainerPort: 8080,
108 Protocol: "tcp",
109 HostIP: "127.0.0.1",
110 },
111 },
112 expected: "127.0.0.1:3000->8080/tcp",
113 },
114 {
115 name: "consecutive tcp ports on localhost",
116 input: []cni.PortMapping{
117 {
118 HostPort: 3000,
119 ContainerPort: 8080,
120 Protocol: "tcp",
121 HostIP: "127.0.0.1",
122 },
123 {
124 HostPort: 3001,
125 ContainerPort: 8081,
126 Protocol: "tcp",
127 HostIP: "127.0.0.1",
128 },
129 },
130 expected: "127.0.0.1:3000-3001->8080-8081/tcp",
131 },
132 {
133 name: "a single tcp port on anyhost",
134 input: []cni.PortMapping{
135 {
136 HostPort: 3000,
137 ContainerPort: 8080,
138 Protocol: "tcp",
139 HostIP: "0.0.0.0",
140 },
141 },
142 expected: "0.0.0.0:3000->8080/tcp",
143 },
144 {
145 name: "a single udp port on anyhost",
146 input: []cni.PortMapping{
147 {
148 HostPort: 3000,
149 ContainerPort: 8080,
150 Protocol: "udp",
151 HostIP: "0.0.0.0",

Callers

nothing calls this directly

Calls 2

FormatPortsFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…