mrlegowatch / GarageStorageSwift

A Swift implementation of GarageStorage. Provides a convenient way to store any kind of data in a repository backed by Core Data.
MIT License
8 stars 1 forks source link

Make a temporary change that throws an error if the core data object's gs_data is nil #22

Closed mrlegowatch closed 3 months ago

mrlegowatch commented 3 months ago

This is a targeted fix to a specific function called from a client app that is crashing while force-unwrapping gs_data, to throw an error instead of making the force-unwrap call. This could be generalized to other functions that also access data (which force unwraps gs_data).

Added a unit test point to reproduce the issue, and verify that it is resolved.

To verify the bug (crash in makeCodable):

Comment out lines 139-142, then uncomment line 137.

Run the unit test and verify that the unit test point fails.

Repeat, restoring lines 139-142, and commenting out line 137.

Run the unit test and verify that the unit test throws the specified error.

kyleronayne commented 3 months ago

Tested using the specified instructions and witnessed the expected results.