2022-09-05 09:06:35 +02:00
|
|
|
package routemanager
|
|
|
|
|
|
|
|
import (
|
2023-05-31 18:25:24 +02:00
|
|
|
"context"
|
2022-09-05 09:06:35 +02:00
|
|
|
"fmt"
|
2023-05-31 18:25:24 +02:00
|
|
|
|
|
|
|
"github.com/netbirdio/netbird/iface"
|
2022-09-05 09:06:35 +02:00
|
|
|
"github.com/netbirdio/netbird/route"
|
|
|
|
)
|
|
|
|
|
|
|
|
// MockManager is the mock instance of a route manager
|
|
|
|
type MockManager struct {
|
|
|
|
UpdateRoutesFunc func(updateSerial uint64, newRoutes []*route.Route) error
|
|
|
|
StopFunc func()
|
|
|
|
}
|
|
|
|
|
2023-06-12 14:43:55 +02:00
|
|
|
// InitialRouteRange mock implementation of InitialRouteRange from Manager interface
|
|
|
|
func (m *MockManager) InitialRouteRange() []string {
|
2023-05-31 18:25:24 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-09-05 09:06:35 +02:00
|
|
|
// UpdateRoutes mock implementation of UpdateRoutes from Manager interface
|
|
|
|
func (m *MockManager) UpdateRoutes(updateSerial uint64, newRoutes []*route.Route) error {
|
|
|
|
if m.UpdateRoutesFunc != nil {
|
|
|
|
return m.UpdateRoutesFunc(updateSerial, newRoutes)
|
|
|
|
}
|
|
|
|
return fmt.Errorf("method UpdateRoutes is not implemented")
|
|
|
|
}
|
|
|
|
|
2023-05-31 18:25:24 +02:00
|
|
|
// Start mock implementation of Start from Manager interface
|
|
|
|
func (m *MockManager) Start(ctx context.Context, iface *iface.WGIface) {
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetRouteChangeListener mock implementation of SetRouteChangeListener from Manager interface
|
|
|
|
func (m *MockManager) SetRouteChangeListener(listener RouteListener) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-09-05 09:06:35 +02:00
|
|
|
// Stop mock implementation of Stop from Manager interface
|
|
|
|
func (m *MockManager) Stop() {
|
|
|
|
if m.StopFunc != nil {
|
|
|
|
m.StopFunc()
|
|
|
|
}
|
|
|
|
}
|