Initial version
Project structure, api, discovery service, docker.
This commit is contained in:
38
pkg/discovery/service_test.go
Normal file
38
pkg/discovery/service_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user