2024-09-19 13:49:28 +02:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestServerPicker_UnavailableServers(t *testing.T) {
|
|
|
|
sp := ServerPicker{
|
|
|
|
TokenStore: nil,
|
|
|
|
PeerID: "test",
|
|
|
|
}
|
|
|
|
|
2024-11-01 12:33:29 +01:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout+1)
|
2024-09-19 13:49:28 +02:00
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
_, err := sp.PickServer(ctx, []string{"rel://dummy1", "rel://dummy2"})
|
|
|
|
if err == nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
cancel()
|
|
|
|
}()
|
|
|
|
|
|
|
|
<-ctx.Done()
|
|
|
|
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
|
|
|
|
t.Errorf("PickServer() took too long to complete")
|
|
|
|
}
|
|
|
|
}
|