Unit test fixup#7
Open
dougluce wants to merge 7 commits intoivolo:masterfrom
dougluce:unit-test-fixup
Open
Conversation
This message was given when rate limiting is hit: ``` express deprecated res.json(status, obj): Use res.status(status).json(obj) instead node_modules/express-rate/lib/rate.js:61:17 ``` The deprecation is mentioned in https://github.com/strongloop/express/releases/tag/4.7.0 Also update the docs and example.
First set of tests cast under Mocha. Simplified them a bit further with async. Did a little refactoring. Hopefully it's better.
Check Redis directly to see whether the key has expired. This should avoid adding fudge factors to the test duration, although fudge is still necessary to compensate for Redis' 1-second expiration resolution. Also expire the proper key out of the store. When the middleware is being used, the route key has the remotekey added to it. Since that's not strictly known until a request is made, I've put in the localhost IP address as that's what express is giving me for a remote address on my box. No clue if that holds up universally. Also tried to make the logic a little cleaner, although it's still far from perfect.
I'm using a single handler for all these tests. This introduces potential for one test to affect other tests (i.e. it's not very "unit-y"). I think the gain in showing resiliancy during multiple uses is worth the downside. Removed the timeout from the Redis test as the interval is now a second and it really should be able to end in under 2.
So that tests will run. NPM also reformatted this thing, looks a little more standard now.
…call' into unit-test-fixup
So the common stuff doesn't look like it has exceptions just for Redis.
Author
|
@ivolo need any help with managing issues or pull requests? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've redone the tests in Mocha with Supertest as a harness for Express. I think I've addressed a couple of problems that the tests had. I hope this may be of some benefit.