This repository has been archived on 2024-02-11. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
astontest/pkg/discovery/service_test.go
derfenix 7864272baa Initial version
Project structure, api, discovery service, docker.
2023-12-06 08:32:01 +03:00

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