Skip to content

Commit

Permalink
test: Add test for metadata json serialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench committed May 25, 2018
1 parent bce1380 commit 6564008
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Tests/BugsnagCrashReportTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -484,4 +484,33 @@ - (void)testHandledReportSeverity {
XCTAssertEqual(report.severity, BSGSeverityWarning);
}

- (void)testHandledReportMetaData {
BugsnagHandledState *state = [BugsnagHandledState handledStateWithSeverityReason:HandledException];
BugsnagMetaData *metaData = [BugsnagMetaData new];
[metaData addAttribute:@"Foo" withValue:@"Bar" toTabWithName:@"Custom"];
NSDictionary *dict = @{@"user.handledState": [state toJson], @"user.metaData": [metaData toDictionary]};

BugsnagCrashReport *report = [[BugsnagCrashReport alloc] initWithKSReport:dict];
XCTAssertNotNil(report.metaData);
XCTAssertEqual(report.metaData.count, 1);
XCTAssertEqualObjects(report.metaData[@"Custom"][@"Foo"], @"Bar");
}

- (void)testUnhandledReportMetaData {
BugsnagMetaData *metaData = [BugsnagMetaData new];
[metaData addAttribute:@"Foo" withValue:@"Bar" toTabWithName:@"Custom"];
NSDictionary *dict = @{@"user.metaData": [metaData toDictionary]};

BugsnagCrashReport *report = [[BugsnagCrashReport alloc] initWithKSReport:dict];
XCTAssertNotNil(report.metaData);
XCTAssertEqual(report.metaData.count, 1);
XCTAssertEqualObjects(report.metaData[@"Custom"][@"Foo"], @"Bar");
}

- (void)testNoReportMetaData {
BugsnagCrashReport *report = [[BugsnagCrashReport alloc] initWithKSReport:@{}];
XCTAssertNotNil(report.metaData);
XCTAssertEqual(report.metaData.count, 0);
}

@end

0 comments on commit 6564008

Please sign in to comment.