39 lines
661 B
Go
39 lines
661 B
Go
package discovery
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"os/signal"
|
|
"sync"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
"go.uber.org/zap/zaptest"
|
|
)
|
|
|
|
func TestIface(t *testing.T) {
|
|
ctx, cancel := signal.NotifyContext(context.Background(), os.Kill, os.Interrupt)
|
|
t.Cleanup(cancel)
|
|
|
|
ctx, _ = context.WithTimeout(ctx, time.Second*5)
|
|
|
|
set, err := NewDiscoverySet(zaptest.NewLogger(t).Named("discovery"), 1234, WithDebug())
|
|
require.NoError(t, err)
|
|
|
|
wg := sync.WaitGroup{}
|
|
|
|
wg.Add(1)
|
|
go set[0].Start(ctx, &wg)
|
|
|
|
go func() {
|
|
for {
|
|
time.Sleep(time.Second)
|
|
}
|
|
}()
|
|
wg.Wait()
|
|
|
|
assert.Len(t, set[0].Nodes(), 1)
|
|
}
|