Skip to content
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

Fix FileAttachment Queue Bug #226

Merged
merged 7 commits into from
Oct 4, 2018
Merged

Fix FileAttachment Queue Bug #226

merged 7 commits into from
Oct 4, 2018

Conversation

electrostat
Copy link
Contributor

Prevent FileAttachment event from being added to queue, in addition to sending it up through attachment logic.

Add in unit test to confirm that whitelisted events are not added to queue.\

Fixes #225

- add return statement  to prevent adding event to queue
- appuserturnstile test
- attachment test
- package-private getQueue method
- new obtainMapboxtelemetry method within tests
@@ -241,6 +241,10 @@ boolean optLocationOut() {
return isLocationOpted;
}

EventsQueue getQueue() {
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the benefit of exposing/relaxing access restriction to queue object? it seems you just want to check if queue is empty, can we instead expose boolean isQueueEmpty() api?

@@ -473,6 +473,38 @@ public void checksSessionIdRotationIntervalNotUpdated() throws Exception {
assertFalse(notUpdatedSessionInterval);
}

@Test
public void checksAppUserTurnstileNotQueued() throws Exception {
Context mockedContext = obtainNetworkConnectedMockedContext();
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a way to avoid mocking external classes (android framework and okhttp) in our tests?

theMapboxTelemetry.enable();
theMapboxTelemetry.push(whitelistedEvent);

assertEquals(0, theMapboxTelemetry.getQueue().queue.size());
Copy link
Contributor

Choose a reason for hiding this comment

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

you could also do assertTrue(theMapboxTelemetry.isQueueEmpty()) if you'd expose boolean isQueueEmpty() api.

- create isQueueEmpty method
- add to tests
- remove mocking calls from within tests
- overload method accidentally split
- fix order of overload method
@@ -241,6 +241,10 @@ boolean optLocationOut() {
return isLocationOpted;
}

Boolean isQueueEmpty() {
Copy link
Contributor

Choose a reason for hiding this comment

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

i'd suggest to avoid boxed types and use primitives, in this particular case boolean is the way to go.

- accidental mistype of `Boolean` v `boolean`
@andrlee andrlee merged commit a2bd2c6 into master Oct 4, 2018
@electrostat electrostat deleted the aa-fileattachment-queue-bug branch October 5, 2018 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants