jaemk / cached

Rust cache structures and easy function memoization
MIT License
1.57k stars 95 forks source link

Improvements to DiskCache tests #193

Closed BaxHugh closed 7 months ago

BaxHugh commented 7 months ago

Since I've been doing some work on the disk.rs module, I've noticed the tests could be improced, both in what's being tested and the descriptiveness of the tests.

In this PR, I haven't changed the functionality of the existing tests, but I've made improvements:

Also, I've added a test for the refreshing functionality.

Just as a note, another way in which the tests can be improved would be to be more specific in what the tests are actually testing, i.e. currently all the tests check that getting a non existent key returns none, but ideally we should have one test for that, and then not tests that behaviour in other tests, i.e. each test should test one thing, and its name should explain what that thing is.

What I'd like to do, if / when I get some time would be to look into having a generic test suite for any cache, and then just plug any specific caching implementation (disk, memory, redis, etc...) into those tests.

Just as a reference: Luca Palmieri has a really nice set of exercises in his testing workshop, which is where I learned about googletest.

jaemk commented 7 months ago

Nice - thanks @BaxHugh !