36 lines
931 B
Go
36 lines
931 B
Go
package vm
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"git.g3e.fr/syonad/two/internal/metadata"
|
|
)
|
|
|
|
func TestMetadataNICs_PrimaryKeepsTheLowestMetricWhateverItsPosition(t *testing.T) {
|
|
nics := []nicData{
|
|
{index: 0, mac: "52:54:00:49:01:0C"},
|
|
{index: 1, mac: "52:54:00:49:02:16", primary: true},
|
|
{index: 2, mac: "52:54:00:49:03:20"},
|
|
}
|
|
|
|
got := metadataNICs(nics)
|
|
|
|
want := []metadata.NIC{
|
|
{MAC: "52:54:00:49:01:0c", RouteMetric: 200},
|
|
{MAC: "52:54:00:49:02:16", RouteMetric: 100},
|
|
{MAC: "52:54:00:49:03:20", RouteMetric: 300},
|
|
}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Errorf("metadataNICs = %+v, attendu %+v", got, want)
|
|
}
|
|
}
|
|
|
|
func TestMetadataNICs_SingleInterface(t *testing.T) {
|
|
got := metadataNICs([]nicData{{mac: "52:54:00:00:00:05", primary: true}})
|
|
|
|
want := []metadata.NIC{{MAC: "52:54:00:00:00:05", RouteMetric: 100}}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Errorf("metadataNICs = %+v, attendu %+v", got, want)
|
|
}
|
|
}
|