StorageBackendMemory should check for registered TypeAdapters
- Dominant language
- Dart
- Stars
- 4.4k
- Forks
- 449
- PR merge metrics
- No merged PRs in 30d
Description
During tests, I use `StorageBackendMemory` to not having to go through the file system. So far, so good. However, after all my tests passed, my app still crashed at runtime, because I did not register a `TypeAdapter` (although I read that it is required in the documentation), since my tests passed fine without it.
I then checked the hive code and saw that the error is thrown from `BinaryWriterImpl`, which gets invoked from `StorageBackendVm.writeFrames`. Since this method is basically a no-op in the `StorageBackendMemory` the exception does never happen during tests.
It would be great if `StorageBackendMemory` could be adapted to do mimic `StorageBackendVm` as close as possible. For this case, it would be enough to simply mimic the `writeFrames` method of `StorageBackendVm`, but do not actually write to the underlying file – i.e. do everything up until the try block. This would ensure that the `TypeAdapeter`s get checked properly.
Reference:
https://github.com/hivedb/hive/blob/a536cf1190bf18c0e213a31e7ba160c9c760b5f0/hive/lib/src/backend/vm/storage_backend_vm.dart#L120-L124
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.