First batch of Add/Del/Update tests.

This commit is contained in:
Milos Gajdos
2019-07-01 22:57:27 +01:00
parent c108b51d2a
commit ffac0b9a18
3 changed files with 208 additions and 4 deletions

View File

@@ -138,6 +138,12 @@ func (t *table) Update(r Route) error {
return ErrRouteNotFound
}
if _, ok := t.m[destAddr][sum]; !ok && r.Policy == AddIfNotExists {
t.m[destAddr][sum] = r
go t.sendEvent(&Event{Type: CreateEvent, Route: r})
return nil
}
// if the route has been found update it
if _, ok := t.m[destAddr][sum]; ok {
t.m[destAddr][sum] = r
@@ -248,7 +254,12 @@ func (t *table) Size() int {
t.RLock()
defer t.RUnlock()
return len(t.m)
size := 0
for dest, _ := range t.m {
size += len(t.m[dest])
}
return size
}
// String returns debug information