8000 Improvements to DiskCache tests by BaxHugh · Pull Request #193 · jaemk/cached · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improvements to DiskCache tests #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 7, 2024

Conversation

BaxHugh
Copy link
Contributor
@BaxHugh BaxHugh commented Apr 3, 2024

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:

  • Use googletest assertions + matchers: These have very nice, descriptive failure messages rather than 'left != right" from std.
  • Added descriptive messages in the assertions
  • Use tempfile::TempDir - the proper way to use the file system in tests (when the TempDir object goes out of scope, the directory gets deleted).
  • Change the test structure / names to be more descriptive.

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
Copy link
Owner
jaemk commented Apr 7, 2024

Nice - thanks @BaxHugh !

@jaemk jaemk merged commit 7662b49 into jaemk:master Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0