update tests and discovery
Some checks failed
Build and Publish / Metadata (push) Has been cancelled
Build and Publish / BuildAndDeployAmd64 (push) Has been cancelled
Build and Publish / BuildAndDeployArm64 (push) Has been cancelled

This commit is contained in:
matst80
2025-11-18 16:40:25 +01:00
parent 718225164f
commit ea247e2600
6 changed files with 146 additions and 36 deletions

View File

@@ -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}
}
}