Skip to content

Conversation

alecgibson
Copy link
Collaborator

This change improves SnapshotRequest test coverage to 100%.

Our current test for checking that a dropped connection works didn't
actually fail properly when removing this.sent = false from
SnapshotRequest._onConnectionStateChanged, so an improved test has
been written that use middleware to wait until the request has
definitely been sent, before dropping the connection and reconnecting.

It also adds a previously uncovered test case for checking that the
connection cannot send the same request multiple times, by using a
similar setup to the rewritten dropped connection case.

This change also adds some documentation recording why we might want to
reset this.sent = false, because just looking at the code it's
unclear why we would ever want to do that.

@coveralls
Copy link

coveralls commented Aug 30, 2018

Coverage Status

Coverage decreased (-0.0005%) to 95.509% when pulling 70cb681 on snapshot-request-test into 0249c91 on master.

@alecgibson alecgibson force-pushed the snapshot-request-test branch from 9f022ff to c3c3c0c Compare August 30, 2018 09:30
This change improves `SnapshotRequest` test coverage to 100%.

Our current test for checking that a dropped connection works didn't
actually fail properly when removing `this.sent = false` from
`SnapshotRequest._onConnectionStateChanged`, so an improved test has
been written that use middleware to wait until the request has
definitely been sent, before dropping the connection and reconnecting.

It also adds a previously uncovered test case for checking that the
connection cannot send the same request multiple times, by using a
similar setup to the rewritten dropped connection case.

This change also adds some documentation recording why we might want to
reset `this.sent = false`, because just looking at the code it's
unclear why we would ever want to do that.
@alecgibson alecgibson force-pushed the snapshot-request-test branch from c3c3c0c to f7dcb37 Compare August 30, 2018 09:35
@alecgibson
Copy link
Collaborator Author

Don't know why it claims that coverage has actually fallen 🤷‍♂️

screen shot 2018-08-30 at 10 43 03

@ericyhwang
Copy link
Contributor

Re the coverage drop, Coveralls thinks this PR has one fewer "relevant line" of code compared to the code on master:

  • Most recent build on master: 2276 of 2383 relevant lines covered (95.51%)
  • This PR: 2275 of 2382 relevant lines covered (95.51%)

Probably due to this on line 61:

- } else if (!this.connection.canSend) {
+ } else {

That's fine. Nothing we can do unless we add coverage for unrelated code.

if (error) return done(error);
done();
var connectionInterrupted = false;
backend.use(backend.MIDDLEWARE_ACTIONS.readSnapshots, function (request, callback) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment about why this needs to use the middleware?

@alecgibson
Copy link
Collaborator Author

@ericyhwang I've added the comment you asked for.

@ericyhwang
Copy link
Contributor

Thanks! I'll merge but hold off on publishing until we've got more changes, as this is just changes to the tests (minus the very minor refactor)

@ericyhwang ericyhwang merged commit e45010c into master Sep 6, 2018
@ericyhwang ericyhwang deleted the snapshot-request-test branch September 6, 2018 18:37
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.

3 participants