Skip to content

Commit

Permalink
Added test for onSessionBlock for session resumption
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Macharg committed Mar 11, 2020
1 parent 445b610 commit 396f7cf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Bugsnag Notifiers on other platforms.

* Added the internal `BugsnagConfiguration.removeOnSessionBlock` methods to allow removal
of callbacks run when a session starts.
[]()
[#483](https://github.com/bugsnag/bugsnag-cocoa/pull/483)

## Bug fixes

Expand Down
18 changes: 16 additions & 2 deletions Tests/BugsnagConfigurationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ - (void)testAddOnSessionBlockThenRemove {
__block XCTestExpectation *expectation2 = [self expectationWithDescription:@"Remove On Session Block 2"];
__block XCTestExpectation *expectation3 = [self expectationWithDescription:@"Remove On Session Block 3"];
expectation3.inverted = YES;

__block XCTestExpectation *expectation4 = [self expectationWithDescription:@"Remove On Session Block 4"];
expectation4.inverted = YES;

BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:nil];
[config setEndpointsForNotify:@"http://notreal.bugsnag.com" sessions:@"http://notreal.bugsnag.com"];
XCTAssertEqual([[config onSessionBlocks] count], 0);
Expand All @@ -170,6 +172,11 @@ - (void)testAddOnSessionBlockThenRemove {
// Should NOT be called
[expectation3 fulfill];
break;
case 3:
// Should NOT be called
[expectation4 fulfill];
break;

}
};

Expand All @@ -180,7 +187,7 @@ - (void)testAddOnSessionBlockThenRemove {
[Bugsnag startBugsnagWithConfiguration:config];
[self waitForExpectations:@[expectation1] timeout:1.0];

// Check it's called on session restart
// Check it's called on new session start
[Bugsnag pauseSession];
called++;
[Bugsnag startSession];
Expand All @@ -192,6 +199,13 @@ - (void)testAddOnSessionBlockThenRemove {
[config removeOnSessionBlock:sessionBlock];
[Bugsnag startSession];
[self waitForExpectations:@[expectation3] timeout:1.0];

// Check it's NOT called on session resume
[Bugsnag pauseSession];
called++;
[config addOnSessionBlock:sessionBlock];
[Bugsnag resumeSession];
[self waitForExpectations:@[expectation4] timeout:1.0];
}

/**
Expand Down

0 comments on commit 396f7cf

Please sign in to comment.