Echo JS 0.11.0

<~>
pid 3935 days ago. link parent 1 point
Your approach is interesting, but to me there is still a little discomfort. And the case study with the cache, don't convinced me to deviate from testing only the public interface.

You said, how can I test the cache functionality in a private function. However, it is easy to test this on the public interface, too.

some pseudo-code:

suite: test caching:
#second request should response content from first response:
   - set TTL 3600
   - set equal (create)timestamp  to cache-test-foo.html and test-cache-bar.html (both with different content)
   - copy test-cache-foo.html to test-cache.html
   - reqA =  request test-cache.html .. test & save response ....
   - copy test-cache-bar.html to test-cache.html
   - reqB = test-cache.html  .. test % save result
   - compare  reqA === reqB, because it should be the cached result

I think with  some more tests you can prove all cases.

And if your cache functionality achieved such great complexity, you should rather think about to  outsource it to an independent module.

Finally, it should be said, thanks for the food for thought, maybe I get in this situation, I'm be able to use your proceeding. :-)

Replies