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