1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 05:57:03 +09:00

Fix check

This commit is contained in:
Mikhail Rakhmanov 2025-04-11 21:17:28 +02:00
parent 9877163c49
commit 5d2e7ce5fe
No known key found for this signature in database
GPG key ID: DED12CFEF5B8396B
2 changed files with 14 additions and 11 deletions

View file

@ -197,17 +197,20 @@ func (fx *fixture) add(t *testing.T, key string, value []byte) {
require.NoError(t, err)
}
func (fx *fixture) check(t *testing.T, key string, value []byte) bool {
kv, decryptor, err := fx.defaultStore.GetAll(ctx, key)
require.NoError(t, err)
for _, v := range kv {
decryptedValue, err := decryptor(v)
require.NoError(t, err)
if bytes.Equal(value, decryptedValue) {
return true
func (fx *fixture) check(t *testing.T, key string, value []byte) (isFound bool) {
err := fx.defaultStore.GetAll(ctx, key, func(decryptor keyvaluestorage.Decryptor, values []innerstorage.KeyValue) error {
for _, v := range values {
decryptedValue, err := decryptor(v)
require.NoError(t, err)
if bytes.Equal(value, decryptedValue) {
isFound = true
break
}
}
}
return false
return nil
})
require.NoError(t, err)
return
}
func newStorageCreatePayload(t *testing.T, keys *accountdata.AccountKeys) spacestorage.SpaceStorageCreatePayload {

View file

@ -53,7 +53,7 @@ type Storage interface {
Prepare() error
Set(ctx context.Context, key string, value []byte) error
SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreKeyValue) error
GetAll(ctx context.Context, key string, get func(decryptor Decryptor, values []innerstorage.KeyValue) error)
GetAll(ctx context.Context, key string, get func(decryptor Decryptor, values []innerstorage.KeyValue) error) error
Iterate(ctx context.Context, f func(key string, values []innerstorage.KeyValue) (bool, error)) error
InnerStorage() innerstorage.KeyValueStorage
}