github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/ipvlan_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 TestCreateIPVlanEndpoint(t *testing.T) { 16 assert := assert.New(t) 17 macAddr := net.HardwareAddr{0x02, 0x00, 0xCA, 0xFE, 0x00, 0x04} 18 19 expected := &IPVlanEndpoint{ 20 NetPair: NetworkInterfacePair{ 21 TapInterface: TapInterface{ 22 ID: "uniqueTestID-5", 23 Name: "br5_kata", 24 TAPIface: NetworkInterface{ 25 Name: "tap5_kata", 26 }, 27 }, 28 VirtIface: NetworkInterface{ 29 Name: "eth5", 30 HardAddr: macAddr.String(), 31 }, 32 33 NetInterworkingModel: NetXConnectTCFilterModel, 34 }, 35 EndpointType: IPVlanEndpointType, 36 } 37 38 result, err := createIPVlanNetworkEndpoint(5, "") 39 assert.NoError(err) 40 41 // the resulting ID will be random - so let's overwrite to test the rest of the flow 42 result.NetPair.ID = "uniqueTestID-5" 43 44 // the resulting mac address will be random - so lets overwrite it 45 result.NetPair.VirtIface.HardAddr = macAddr.String() 46 47 assert.Exactly(result, expected) 48 }