mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-03 21:16:35 +00:00
Much better test for attachment persisting
This commit is contained in:
parent
535537aa73
commit
82b217f19d
@ -65,7 +65,6 @@ NSString *const kBITCrashManagerStatus = @"BITCrashManagerStatus";
|
||||
|
||||
@interface BITCrashManager ()
|
||||
|
||||
@property (nonatomic, strong) NSFileManager *fileManager;
|
||||
@property (nonatomic, copy, setter = setAlertViewHandler:) CustomAlertViewHandler alertViewHandler;
|
||||
|
||||
@end
|
||||
|
||||
@ -36,6 +36,8 @@
|
||||
|
||||
@property (nonatomic) NSUncaughtExceptionHandler *exceptionHandler;
|
||||
|
||||
@property (nonatomic, strong) NSFileManager *fileManager;
|
||||
|
||||
@property (nonatomic, strong) BITPLCrashReporter *plCrashReporter;
|
||||
|
||||
@property (nonatomic) NSString *lastCrashFilename;
|
||||
@ -66,6 +68,8 @@
|
||||
- (void)persistUserProvidedCrashDescription:(NSString *)userProvidedCrashDescription;
|
||||
- (void)persistAttachment:(BITCrashAttachment *)attachment withFilename:(NSString *)filename;
|
||||
|
||||
- (BITCrashAttachment *)attachmentForCrashReport:(NSString *)filename;
|
||||
|
||||
- (void)invokeDelayedProcessing;
|
||||
- (void)sendCrashReports;
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
|
||||
#import "BITTestHelper.h"
|
||||
|
||||
#define kBITCrashMetaAttachment @"BITCrashMetaAttachment"
|
||||
|
||||
@interface BITCrashManagerTests : SenTestCase
|
||||
|
||||
@ -91,12 +92,20 @@
|
||||
}
|
||||
|
||||
- (void)testPersistAttachment {
|
||||
BITCrashAttachment *attachment = mock([BITCrashAttachment class]);
|
||||
NSString *filename = @"testAttachment";
|
||||
NSString *filename = @"TestAttachment";
|
||||
NSData *data = [[NSData alloc] initWithBase64Encoding:@"TestData"];
|
||||
NSString* type = @"text/plain";
|
||||
|
||||
[_sut persistAttachment:attachment withFilename:filename];
|
||||
BITCrashAttachment *originalAttachment = [[BITCrashAttachment alloc] initWithFilename:filename attachmentData:data contentType:type];
|
||||
NSString *attachmentFilename = [_sut.getCrashesDir stringByAppendingPathComponent:@"testAttachment"];
|
||||
|
||||
[given([NSData dataWithContentsOfFile:[filename stringByAppendingString:@".data"]]) willReturn:[NSMutableDictionary class]];
|
||||
[_sut persistAttachment:originalAttachment withFilename:attachmentFilename];
|
||||
|
||||
BITCrashAttachment *decodedAttachment = [_sut attachmentForCrashReport:attachmentFilename];
|
||||
|
||||
assertThat(decodedAttachment.filename, equalTo(filename));
|
||||
assertThat(decodedAttachment.attachmentData, equalTo(data));
|
||||
assertThat(decodedAttachment.contentType, equalTo(type));
|
||||
}
|
||||
|
||||
#pragma mark - Helper
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user