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

Function TestConvertServiceNetworks

cli/compose/convert/service_test.go:250–291  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

248}
249
250func TestConvertServiceNetworks(t *testing.T) {
251 networkConfigs := networkMap{
252 "front": composetypes.NetworkConfig{
253 External: composetypes.External{External: true},
254 Name: "fronttier",
255 },
256 "back": composetypes.NetworkConfig{},
257 }
258 networks := map[string]*composetypes.ServiceNetworkConfig{
259 "front": {
260 Aliases: []string{"something"},
261 DriverOpts: map[string]string{
262 "driver.opt1": "optval1",
263 "driver.opt2": "optval2",
264 },
265 },
266 "back": {
267 Aliases: []string{"other"},
268 },
269 }
270
271 configs, err := convertServiceNetworks(
272 networks, networkConfigs, NewNamespace("foo"), "service")
273
274 expected := []swarm.NetworkAttachmentConfig{
275 {
276 Target: "foo_back",
277 Aliases: []string{"other", "service"},
278 },
279 {
280 Target: "fronttier",
281 Aliases: []string{"something", "service"},
282 DriverOpts: map[string]string{
283 "driver.opt1": "optval1",
284 "driver.opt2": "optval2",
285 },
286 },
287 }
288
289 assert.NilError(t, err)
290 assert.Check(t, is.DeepEqual(expected, configs))
291}
292
293func TestConvertServiceNetworksCustomDefault(t *testing.T) {
294 networkConfigs := networkMap{

Callers

nothing calls this directly

Calls 2

convertServiceNetworksFunction · 0.85
NewNamespaceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…