Loading server/core_storage_test.go +71 −0 Original line number Diff line number Diff line Loading @@ -2082,6 +2082,77 @@ func TestStorageListNoRepeats(t *testing.T) { assert.Equal(t, "", values.Cursor, "cursor was not nil") } func TestStorageOverrwriteEmptyAndNonEmptyVersions(t *testing.T) { db := NewDB(t) defer db.Close() uid := uuid.Must(uuid.NewV4()) InsertUser(t, db, uid) collection := GenerateString() ops := StorageOpWrites{ &StorageOpWrite{ OwnerID: uid.String(), Object: &api.WriteStorageObject{ Collection: collection, Key: "7", Value: `{"testKey":"testValue1"}`, PermissionRead: &wrapperspb.Int32Value{Value: 2}, PermissionWrite: &wrapperspb.Int32Value{Value: 1}, Version: "", }, }, } acks, code, err := StorageWriteObjects(context.Background(), logger, db, metrics, storageIdx, false, ops) assert.Nil(t, err, "err was not nil") assert.Equal(t, codes.OK, code, "code was not OK") assert.NotNil(t, acks, "acks was nil") ops = StorageOpWrites{ &StorageOpWrite{ OwnerID: uid.String(), Object: &api.WriteStorageObject{ Collection: collection, Key: "7", Value: `{"testKey":"testValue2"}`, PermissionRead: &wrapperspb.Int32Value{Value: 2}, PermissionWrite: &wrapperspb.Int32Value{Value: 1}, Version: "", }, }, } acks, code, err = StorageWriteObjects(context.Background(), logger, db, metrics, storageIdx, false, ops) assert.Nil(t, err, "err was not nil") assert.Equal(t, codes.OK, code, "code was not OK") assert.NotNil(t, acks, "acks was nil") assert.Len(t, acks.Acks, 1, "acks length was not 1") ops = StorageOpWrites{ &StorageOpWrite{ OwnerID: uid.String(), Object: &api.WriteStorageObject{ Collection: collection, Key: "7", Value: `{"testKey":"testValue3"}`, PermissionRead: &wrapperspb.Int32Value{Value: 2}, PermissionWrite: &wrapperspb.Int32Value{Value: 1}, Version: acks.Acks[0].Version, }, }, } acks, code, err = StorageWriteObjects(context.Background(), logger, db, metrics, storageIdx, false, ops) assert.Nil(t, err, "err was not nil") assert.Equal(t, codes.OK, code, "code was not OK") assert.NotNil(t, acks, "acks was nil") assert.Len(t, acks.Acks, 1, "acks length was not 1") } // DB State and expected outcome when performing write op type writeTestDBState struct { write int Loading Loading
server/core_storage_test.go +71 −0 Original line number Diff line number Diff line Loading @@ -2082,6 +2082,77 @@ func TestStorageListNoRepeats(t *testing.T) { assert.Equal(t, "", values.Cursor, "cursor was not nil") } func TestStorageOverrwriteEmptyAndNonEmptyVersions(t *testing.T) { db := NewDB(t) defer db.Close() uid := uuid.Must(uuid.NewV4()) InsertUser(t, db, uid) collection := GenerateString() ops := StorageOpWrites{ &StorageOpWrite{ OwnerID: uid.String(), Object: &api.WriteStorageObject{ Collection: collection, Key: "7", Value: `{"testKey":"testValue1"}`, PermissionRead: &wrapperspb.Int32Value{Value: 2}, PermissionWrite: &wrapperspb.Int32Value{Value: 1}, Version: "", }, }, } acks, code, err := StorageWriteObjects(context.Background(), logger, db, metrics, storageIdx, false, ops) assert.Nil(t, err, "err was not nil") assert.Equal(t, codes.OK, code, "code was not OK") assert.NotNil(t, acks, "acks was nil") ops = StorageOpWrites{ &StorageOpWrite{ OwnerID: uid.String(), Object: &api.WriteStorageObject{ Collection: collection, Key: "7", Value: `{"testKey":"testValue2"}`, PermissionRead: &wrapperspb.Int32Value{Value: 2}, PermissionWrite: &wrapperspb.Int32Value{Value: 1}, Version: "", }, }, } acks, code, err = StorageWriteObjects(context.Background(), logger, db, metrics, storageIdx, false, ops) assert.Nil(t, err, "err was not nil") assert.Equal(t, codes.OK, code, "code was not OK") assert.NotNil(t, acks, "acks was nil") assert.Len(t, acks.Acks, 1, "acks length was not 1") ops = StorageOpWrites{ &StorageOpWrite{ OwnerID: uid.String(), Object: &api.WriteStorageObject{ Collection: collection, Key: "7", Value: `{"testKey":"testValue3"}`, PermissionRead: &wrapperspb.Int32Value{Value: 2}, PermissionWrite: &wrapperspb.Int32Value{Value: 1}, Version: acks.Acks[0].Version, }, }, } acks, code, err = StorageWriteObjects(context.Background(), logger, db, metrics, storageIdx, false, ops) assert.Nil(t, err, "err was not nil") assert.Equal(t, codes.OK, code, "code was not OK") assert.NotNil(t, acks, "acks was nil") assert.Len(t, acks.Acks, 1, "acks length was not 1") } // DB State and expected outcome when performing write op type writeTestDBState struct { write int Loading