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

Unit tests should model the right way to initialize Garage #23

Closed mrlegowatch closed 4 months ago

mrlegowatch commented 4 months ago

A reviewer asked why the unit tests are creating garages in their setup functions to delete all objects when the individual test functions also create their own garages, and the answer is not obvious, which suggests that the sample code should probably be updated to model the right way to initialize a Garage.

The short answer is, when initializing a Garage without any persistent store descriptions, they wind up sharing the same default persistent store description. So, essentially every instance created in this way shares the same local storage. This is actually a bad practice.

Suggestions: