MCPcopy
hub / github.com/docker/compose / TestCreateEndpointSettings

Function TestCreateEndpointSettings

pkg/compose/create_test.go:322–366  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

320}
321
322func TestCreateEndpointSettings(t *testing.T) {
323 eps, err := createEndpointSettings(&composetypes.Project{
324 Name: "projName",
325 }, composetypes.ServiceConfig{
326 Name: "serviceName",
327 ContainerName: "containerName",
328 Networks: map[string]*composetypes.ServiceNetworkConfig{
329 "netName": {
330 Priority: 100,
331 Aliases: []string{"alias1", "alias2"},
332 Ipv4Address: "10.16.17.18",
333 Ipv6Address: "fdb4:7a7f:373a:3f0c::42",
334 LinkLocalIPs: []string{"169.254.10.20"},
335 MacAddress: "02:00:00:00:00:01",
336 DriverOpts: composetypes.Options{
337 "driverOpt1": "optval1",
338 "driverOpt2": "optval2",
339 },
340 },
341 },
342 }, 0, "netName", []string{"link1", "link2"}, true)
343 assert.NilError(t, err)
344 macAddr, _ := net.ParseMAC("02:00:00:00:00:01")
345 assert.Check(t, cmp.DeepEqual(eps, &network.EndpointSettings{
346 IPAMConfig: &network.EndpointIPAMConfig{
347 IPv4Address: netip.MustParseAddr("10.16.17.18").Unmap(),
348 IPv6Address: netip.MustParseAddr("fdb4:7a7f:373a:3f0c::42"),
349 LinkLocalIPs: []netip.Addr{netip.MustParseAddr("169.254.10.20").Unmap()},
350 },
351 Links: []string{"link1", "link2"},
352 Aliases: []string{"containerName", "serviceName", "alias1", "alias2"},
353 MacAddress: network.HardwareAddr(macAddr),
354 DriverOpts: map[string]string{
355 "driverOpt1": "optval1",
356 "driverOpt2": "optval2",
357 },
358
359 // FIXME(robmry) - IPAddress and IPv6Gateway are "operational data" fields...
360 // - The IPv6 address here is the container's address, not the gateway.
361 // - Both fields will be cleared by the daemon, but they could be removed from
362 // the request.
363 IPAddress: netip.MustParseAddr("10.16.17.18").Unmap(),
364 IPv6Gateway: netip.MustParseAddr("fdb4:7a7f:373a:3f0c::42"),
365 }, cmpopts.EquateComparable(netip.Addr{})))
366}
367
368func Test_buildContainerVolumes(t *testing.T) {
369 pwd, err := os.Getwd()

Callers

nothing calls this directly

Calls 1

createEndpointSettingsFunction · 0.85

Tested by

no test coverage detected