Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bamx23 committed Sep 7, 2024
1 parent e1721d7 commit 5ac290c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 32 deletions.
32 changes: 0 additions & 32 deletions Tests/KSCrashFiltersTests/KSCrashDoctor_Tests.m

This file was deleted.

48 changes: 48 additions & 0 deletions Tests/KSCrashFiltersTests/KSCrashReportFilterDoctor_Tests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#import <XCTest/XCTest.h>

#import "KSCrashReportFilterDoctor.h"

Check failure on line 3 in Tests/KSCrashFiltersTests/KSCrashReportFilterDoctor_Tests.m

View workflow job for this annotation

GitHub Actions / Formatting Check

Tests/KSCrashFiltersTests/KSCrashReportFilterDoctor_Tests.m:3:1: error: code should be clang-formatted [-Wclang-format-violations]
#import "KSCrashReport.h"
#import "KSCrashReportFields.h"
#import "KSTestModuleConfig.h"

@interface KSCrashDoctor_Tests : XCTestCase
@end

@implementation KSCrashDoctor_Tests

- (KSCrashReportDictionary *)_crashReportAsJSON:(NSString *)filename
{
NSURL *url = [KS_TEST_MODULE_BUNDLE URLForResource:filename withExtension:@"json"];
NSData *data = [NSData dataWithContentsOfURL:url];
NSDictionary *reportDict = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
return [KSCrashReportDictionary reportWithValue:reportDict];
}

- (KSCrashReportDictionary *)_filteredReport:(KSCrashReportDictionary *)report
{
KSCrashReportDictionary *__block result = nil;
KSCrashReportFilterDoctor *filter = [KSCrashReportFilterDoctor new];
[filter filterReports:@[report] onCompletion:^(NSArray<id<KSCrashReport>> *filteredReports, NSError *error) {

Check failure on line 25 in Tests/KSCrashFiltersTests/KSCrashReportFilterDoctor_Tests.m

View workflow job for this annotation

GitHub Actions / Formatting Check

Tests/KSCrashFiltersTests/KSCrashReportFilterDoctor_Tests.m:25:29: error: code should be clang-formatted [-Wclang-format-violations]

Check failure on line 25 in Tests/KSCrashFiltersTests/KSCrashReportFilterDoctor_Tests.m

View workflow job for this annotation

GitHub Actions / Formatting Check

Tests/KSCrashFiltersTests/KSCrashReportFilterDoctor_Tests.m:25:35: error: code should be clang-formatted [-Wclang-format-violations]

Check failure on line 25 in Tests/KSCrashFiltersTests/KSCrashReportFilterDoctor_Tests.m

View workflow job for this annotation

GitHub Actions / Formatting Check

Tests/KSCrashFiltersTests/KSCrashReportFilterDoctor_Tests.m:25:36: error: code should be clang-formatted [-Wclang-format-violations]

Check failure on line 25 in Tests/KSCrashFiltersTests/KSCrashReportFilterDoctor_Tests.m

View workflow job for this annotation

GitHub Actions / Formatting Check

Tests/KSCrashFiltersTests/KSCrashReportFilterDoctor_Tests.m:25:114: error: code should be clang-formatted [-Wclang-format-violations]
result = filteredReports.firstObject;

Check failure on line 26 in Tests/KSCrashFiltersTests/KSCrashReportFilterDoctor_Tests.m

View workflow job for this annotation

GitHub Actions / Formatting Check

Tests/KSCrashFiltersTests/KSCrashReportFilterDoctor_Tests.m:26:46: error: code should be clang-formatted [-Wclang-format-violations]
XCTAssertNil(error);

Check failure on line 27 in Tests/KSCrashFiltersTests/KSCrashReportFilterDoctor_Tests.m

View workflow job for this annotation

GitHub Actions / Formatting Check

Tests/KSCrashFiltersTests/KSCrashReportFilterDoctor_Tests.m:27:29: error: code should be clang-formatted [-Wclang-format-violations]
}];
return result;
}

- (void)testGracefulTermination
{
KSCrashReportDictionary *report = [self _crashReportAsJSON:@"sigterm"];
KSCrashReportDictionary *resultReport = [self _filteredReport:report];
NSString *diagnostic = resultReport.value[KSCrashField_Crash][KSCrashField_Diagnosis];
XCTAssertEqual(diagnostic, @"The OS request the app be gracefully terminated.");
}

- (void)testOOM
{
KSCrashReportDictionary *report = [self _crashReportAsJSON:@"oom"];
KSCrashReportDictionary *resultReport = [self _filteredReport:report];
NSString *diagnostic = resultReport.value[KSCrashField_Crash][KSCrashField_Diagnosis];
XCTAssertEqual(diagnostic, @"The app was terminated due to running out of memory (OOM).");
}

@end

0 comments on commit 5ac290c

Please sign in to comment.