Fix requestmanager test

This commit is contained in:
mcrakhman 2023-06-28 11:59:13 +02:00
parent 0ffbb6fa5a
commit ffd613a5fc
No known key found for this signature in database
GPG Key ID: DED12CFEF5B8396B

View File

@ -2,6 +2,10 @@ package requestmanager
import ( import (
"context" "context"
"sync"
"testing"
"time"
"github.com/anyproto/any-sync/commonspace/objectsync" "github.com/anyproto/any-sync/commonspace/objectsync"
"github.com/anyproto/any-sync/commonspace/objectsync/mock_objectsync" "github.com/anyproto/any-sync/commonspace/objectsync/mock_objectsync"
"github.com/anyproto/any-sync/commonspace/spacesyncproto" "github.com/anyproto/any-sync/commonspace/spacesyncproto"
@ -13,9 +17,6 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"storj.io/drpc" "storj.io/drpc"
"storj.io/drpc/drpcconn" "storj.io/drpc/drpcconn"
"sync"
"testing"
"time"
) )
type fixture struct { type fixture struct {
@ -146,6 +147,7 @@ func TestRequestManager_QueueRequest(t *testing.T) {
_, ok = msgs.Load("otherId1") _, ok = msgs.Load("otherId1")
require.True(t, ok) require.True(t, ok)
close(msgRelease) close(msgRelease)
fx.requestManager.Close(context.Background())
}) })
t.Run("no requests after close", func(t *testing.T) { t.Run("no requests after close", func(t *testing.T) {
@ -181,9 +183,9 @@ func TestRequestManager_QueueRequest(t *testing.T) {
close(msgRelease) close(msgRelease)
// waiting to know if the second one is not taken // waiting to know if the second one is not taken
// because the manager is now closed // because the manager is now closed
time.Sleep(100 * time.Millisecond) time.Sleep(200 * time.Millisecond)
_, ok = msgs.Load("id2") _, ok = msgs.Load("id2")
require.False(t, ok) require.False(t, ok)
fx.requestManager.Close(context.Background())
}) })
} }