44 "errors"
55 "fmt"
66 "io"
7+ "net"
78 "net/netip"
89 "os"
910 "runtime"
@@ -20,6 +21,14 @@ import (
2021 "gotest.tools/v3/skip"
2122)
2223
24+ func mustParseMAC (s string ) networktypes.HardwareAddr {
25+ mac , err := net .ParseMAC (s )
26+ if err != nil {
27+ panic (err )
28+ }
29+ return networktypes .HardwareAddr (mac )
30+ }
31+
2332func TestValidateAttach (t * testing.T ) {
2433 valid := []string {
2534 "stdin" ,
@@ -353,7 +362,7 @@ func TestParseWithMacAddress(t *testing.T) {
353362 }
354363 _ , hostConfig , nwConfig := mustParse (t , validMacAddress )
355364 defaultNw := hostConfig .NetworkMode .NetworkName ()
356- if nwConfig .EndpointsConfig [defaultNw ].MacAddress != "92:d0:c6:0a:29:33" {
365+ if nwConfig .EndpointsConfig [defaultNw ].MacAddress . String () != "92:d0:c6:0a:29:33" {
357366 t .Fatalf ("Expected the default endpoint to have the MacAddress '92:d0:c6:0a:29:33' set, got '%v'" , nwConfig .EndpointsConfig [defaultNw ].MacAddress )
358367 }
359368}
@@ -650,7 +659,7 @@ func TestParseNetworkConfig(t *testing.T) {
650659 Aliases : []string {"web3" },
651660 },
652661 "net4" : {
653- MacAddress : "02:32:1c:23:00:04" ,
662+ MacAddress : mustParseMAC ( "02:32:1c:23:00:04" ) ,
654663 IPAMConfig : & networktypes.EndpointIPAMConfig {
655664 LinkLocalIPs : []netip.Addr {netip .MustParseAddr ("169.254.169.254" )},
656665 },
@@ -672,7 +681,7 @@ func TestParseNetworkConfig(t *testing.T) {
672681 IPv6Address : netip .MustParseAddr ("2001:db8::8822" ),
673682 },
674683 Aliases : []string {"web1" , "web2" },
675- MacAddress : "02:32:1c:23:00:04" ,
684+ MacAddress : mustParseMAC ( "02:32:1c:23:00:04" ) ,
676685 },
677686 },
678687 expectedHostCfg : container.HostConfig {NetworkMode : "net1" },
@@ -689,7 +698,7 @@ func TestParseNetworkConfig(t *testing.T) {
689698 expected : map [string ]* networktypes.EndpointSettings {
690699 "net1" : {
691700 Aliases : []string {"foobar" },
692- MacAddress : "52:0f:f3:dc:50:10" ,
701+ MacAddress : mustParseMAC ( "52:0f:f3:dc:50:10" ) ,
693702 },
694703 },
695704 expectedHostCfg : container.HostConfig {NetworkMode : "net1" },
0 commit comments