add sleep for test context switch

This commit is contained in:
William Banfield
2021-08-13 14:17:11 -04:00
parent f154067401
commit 208bf0541b
2 changed files with 3 additions and 2 deletions

View File

@@ -3,7 +3,6 @@ package inspect
import (
"context"
"errors"
"fmt"
"net"
"sync"
@@ -104,7 +103,6 @@ func (inspect *Inspect) Run(ctx context.Context) error {
return err
}
defer func() {
fmt.Println("stopping indexer")
err := inspect.indexerService.Stop()
if err != nil {
inspect.logger.Error("indexer stopped with error", "err", err)

View File

@@ -8,6 +8,7 @@ import (
"strings"
"sync"
"testing"
"time"
"github.com/fortytw2/leaktest"
"github.com/stretchr/testify/mock"
@@ -81,6 +82,8 @@ func TestInspectServeInfoRPC(t *testing.T) {
defer wg.Done()
require.NoError(t, d.Run(ctx))
}()
// force context switch
time.Sleep(10 * time.Millisecond)
requireConnect(t, rpcConfig.ListenAddress, 15)
cli, err := http_client.New(rpcConfig.ListenAddress)
require.NoError(t, err)