github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/bridgedmacvlan_endpoint_test.go (about) 1 // Copyright (c) 2018 Intel Corporation 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 // 5 6 package virtcontainers 7 8 import ( 9 "net" 10 "testing" 11 12 "github.com/stretchr/testify/assert" 13 ) 14 15 func TestCreateBridgedMacvlanEndpoint(t *testing.T) { 16 macAddr := net.HardwareAddr{0x02, 0x00, 0xCA, 0xFE, 0x00, 0x04} 17 18 expected := &BridgedMacvlanEndpoint{ 19 NetPair: NetworkInterfacePair{ 20 TapInterface: TapInterface{ 21 ID: "uniqueTestID-4", 22 Name: "br4_kata", 23 TAPIface: NetworkInterface{ 24 Name: "tap4_kata", 25 }, 26 }, 27 VirtIface: NetworkInterface{ 28 Name: "eth4", 29 HardAddr: macAddr.String(), 30 }, 31 NetInterworkingModel: DefaultNetInterworkingModel, 32 }, 33 EndpointType: BridgedMacvlanEndpointType, 34 } 35 36 result, err := createBridgedMacvlanNetworkEndpoint(4, "", DefaultNetInterworkingModel) 37 assert.NoError(t, err) 38 39 // the resulting ID will be random - so let's overwrite to test the rest of the flow 40 result.NetPair.ID = "uniqueTestID-4" 41 42 // the resulting mac address will be random - so lets overwrite it 43 result.NetPair.VirtIface.HardAddr = macAddr.String() 44 45 assert.Exactly(t, result, expected) 46 }