update tests and discovery
This commit is contained in:
@@ -2,9 +2,8 @@ package discovery
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
"sync"
|
||||
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
)
|
||||
|
||||
// MockDiscovery is an in-memory Discovery implementation for tests.
|
||||
@@ -56,14 +55,12 @@ func (m *MockDiscovery) AddHost(host string) {
|
||||
if m.closed {
|
||||
return
|
||||
}
|
||||
for _, h := range m.hosts {
|
||||
if h == host {
|
||||
return
|
||||
}
|
||||
if slices.Contains(m.hosts, host) {
|
||||
return
|
||||
}
|
||||
m.hosts = append(m.hosts, host)
|
||||
if m.started {
|
||||
m.events <- HostChange{Host: host, Type: watch.Added}
|
||||
m.events <- HostChange{Host: host, IsReady: true}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +83,7 @@ func (m *MockDiscovery) RemoveHost(host string) {
|
||||
}
|
||||
m.hosts = append(m.hosts[:idx], m.hosts[idx+1:]...)
|
||||
if m.started {
|
||||
m.events <- HostChange{Host: host, Type: watch.Deleted}
|
||||
m.events <- HostChange{Host: host, IsReady: false}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user