1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-08 05:47:07 +09:00

Fix concurrent tests

This commit is contained in:
kirillston 2025-06-06 19:02:06 +02:00
parent 80a0f213ff
commit 8cc1320f3e
No known key found for this signature in database
GPG key ID: BE4BF014F0ECDFE8
2 changed files with 9 additions and 9 deletions

View file

@ -1134,14 +1134,13 @@ func TestHistory_Show(t *testing.T) {
Model: &pb.Change{},
}
heads := []string{"id", "id1"}
changesMap := map[string][]*objecttree.Change{
"id1 id": {root, ch1},
"id id1": {root, ch},
"id id1": {root, ch1},
"id1 id": {root, ch},
objectId: {root, ch, ch1},
}
h := newFixtureShow(t, changesMap, heads, objectId, spaceID)
h := newFixtureShow(t, changesMap, objectId, spaceID)
// when
fullId := domain.FullID{ObjectID: objectId, SpaceID: spaceID}
@ -1214,7 +1213,7 @@ func newFixtureDiffVersions(t *testing.T,
}
}
func newFixtureShow(t *testing.T, changes map[string][]*objecttree.Change, heads []string, objectId, spaceID string) *historyFixture {
func newFixtureShow(t *testing.T, changes map[string][]*objecttree.Change, objectId, spaceID string) *historyFixture {
spaceService := mock_space.NewMockService(t)
space := mock_clientspace.NewMockSpace(t)
ctrl := gomock.NewController(t)
@ -1232,7 +1231,7 @@ func newFixtureShow(t *testing.T, changes map[string][]*objecttree.Change, heads
return &historyStub{
objectId: objectId,
changes: chs,
heads: heads,
heads: opts.Heads,
}, nil
}).AnyTimes()
space.EXPECT().TreeBuilder().Return(treeBuilder)

View file

@ -1,6 +1,7 @@
package emailcollector
import (
"sync/atomic"
"testing"
"github.com/stretchr/testify/assert"
@ -188,10 +189,10 @@ func TestEmailCollector(t *testing.T) {
t.Run("should handle concurrent requests", func(t *testing.T) {
// Given
var callCount int
var callCount atomic.Uint32
collector := &mockEmailCollector{
onSetRequest: func(req *pb.RpcMembershipGetVerificationEmailRequest) error {
callCount++
callCount.Add(1)
assert.Equal(t, "test@example.com", req.Email)
return nil
},
@ -214,6 +215,6 @@ func TestEmailCollector(t *testing.T) {
for i := 0; i < 10; i++ {
<-done
}
assert.Equal(t, 10, callCount)
assert.Equal(t, uint32(10), callCount.Load())
})
}