github.com/telepresenceio/telepresence/v2@v2.20.0-pro.6.0.20240517030216-236ea954e789/pkg/routing/routing_test.go (about) 1 package routing 2 3 import ( 4 "net" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 9 "github.com/datawire/dlib/dlog" 10 ) 11 12 func TestGetRoutingTable_defaultRoute(t *testing.T) { 13 ctx := dlog.NewTestContext(t, true) 14 rt, err := GetRoutingTable(ctx) 15 assert.NoError(t, err) 16 var dflt *Route 17 for _, r := range rt { 18 if r.Default { 19 dflt = r 20 break 21 } 22 } 23 assert.NotNil(t, dflt) 24 assert.False(t, dflt.Gateway.Equal(net.IP{0, 0, 0, 0})) 25 } 26 27 func TestGetRoutingTable(t *testing.T) { 28 ctx := dlog.NewTestContext(t, true) 29 rt, err := GetRoutingTable(ctx) 30 assert.NoError(t, err) 31 assert.NotEmpty(t, rt) 32 for _, r := range rt { 33 assert.NotNil(t, r.LocalIP) 34 assert.NotNil(t, r.Interface) 35 assert.NotNil(t, r.RoutedNet) 36 } 37 }