ml-archive / Cashier

An easy to use 2-layered object cache for iOS.

Home Page:https://nodesagency.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add tests

mariusc opened this issue · comments

  • tests for NOCache (renamed to Cashier)
    • test object insertion in cache
    • test object fetching from cache
    • test object deletion from cache
    • test cache clearing
    • test image insertion in cache
    • test image deletion from cache
    • test image fetching from cache
    • test cache is automatically cleared on memory warning
    • test cache persistence across versions
    • test cache lifespan
  • tests for NOPersistentStore

Working on branch https://github.com/nodes-ios/Cashier/tree/mariusc-tests for Cashier tests

I'm not really sure how to test the cache persistence across versions. Looks like I would need to simulate a change in the CFBundleShortVersionString, and I don't know how to do that. @nodes-ios/developer-team any suggestions on this one?

Look at how the cache compares versions. I think you should be able to manually change that in NSUserDefaults, so you could make the cache think there's new version :)

I made the change manually in NSUserDefaults, but my test failed. So I investigated a bit more and saw that [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] is nil and [[NSBundle mainBundle] infoDictionary] is an empty dictionary.

image.

That is most likely because of the tests bundle. As a quick hack, swizzling the infoDictionary getter method of NSBundle with a custom implementation would work. Then you can easily control version numbers returned from your custom infoDictionary.

Made PR for Cashier tests #13. NOPersistentStore ignored for the moment

We have added some tests for NOPersistentStore in the Swift types tests. As always, tests can always be improved. But it's safe to close this issue now.