mirror of
https://github.com/netbirdio/netbird.git
synced 2025-08-08 23:05:28 +02:00
chore: [Signal] synchronize peer registry
This commit is contained in:
@ -4,6 +4,20 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRegistry_GetNonExistentPeer(t *testing.T) {
|
||||
r := NewRegistry()
|
||||
|
||||
peer, ok := r.Get("non_existent_peer")
|
||||
|
||||
if peer != nil {
|
||||
t.Errorf("expected non_existent_peer not found in the registry")
|
||||
}
|
||||
|
||||
if ok {
|
||||
t.Errorf("expected non_existent_peer not found in the registry")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegistry_Register(t *testing.T) {
|
||||
r := NewRegistry()
|
||||
peer1 := NewPeer("test_peer_1", nil)
|
||||
@ -11,15 +25,11 @@ func TestRegistry_Register(t *testing.T) {
|
||||
r.Register(peer1)
|
||||
r.Register(peer2)
|
||||
|
||||
if len(r.Peers) != 2 {
|
||||
t.Errorf("expected 2 registered peers")
|
||||
}
|
||||
|
||||
if _, ok := r.Peers["test_peer_1"]; !ok {
|
||||
if _, ok := r.Get("test_peer_1"); !ok {
|
||||
t.Errorf("expected test_peer_1 not found in the registry")
|
||||
}
|
||||
|
||||
if _, ok := r.Peers["test_peer_2"]; !ok {
|
||||
if _, ok := r.Get("test_peer_2"); !ok {
|
||||
t.Errorf("expected test_peer_2 not found in the registry")
|
||||
}
|
||||
}
|
||||
@ -33,15 +43,11 @@ func TestRegistry_Deregister(t *testing.T) {
|
||||
|
||||
r.Deregister(peer1)
|
||||
|
||||
if len(r.Peers) != 1 {
|
||||
t.Errorf("expected 1 registered peers after deregistring")
|
||||
}
|
||||
|
||||
if _, ok := r.Peers["test_peer_1"]; ok {
|
||||
if _, ok := r.Get("test_peer_1"); ok {
|
||||
t.Errorf("expected test_peer_1 to absent in the registry after deregistering")
|
||||
}
|
||||
|
||||
if _, ok := r.Peers["test_peer_2"]; !ok {
|
||||
if _, ok := r.Get("test_peer_2"); !ok {
|
||||
t.Errorf("expected test_peer_2 not found in the registry")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user