@@ -146,55 +146,58 @@ - (void)testPersistWhenArchiveFails {
146146}
147147
148148- (void )testCloseRequestsArentPersisted {
149- XCTestExpectation *expectation = [self expectationWithDescription: @" PersistExpectation" ];
150-
151- id archiverMock = OCMClassMock ([NSKeyedArchiver class ]);
152- [[archiverMock reject ] archiveRootObject: [OCMArg any ] toFile: [OCMArg any ]];
153- [[[archiverMock expect ]
154- andReturn: [NSData data ]]
155- archivedDataWithRootObject: [OCMArg checkWithBlock: ^BOOL (NSArray *reqs) {
156- if ([reqs isKindOfClass: [NSArray class ]]) {
157- XCTAssert (reqs.count == 0 );
158- BNCAfterSecondsPerformBlock (0.01 , ^{ [self safelyFulfillExpectation: expectation]; });
159- return YES ;
160- }
161- return NO ;
162- }]];
163-
164- BNCServerRequestQueue *requestQueue = [[BNCServerRequestQueue alloc ] init ];
165- BranchCloseRequest *closeRequest = [[BranchCloseRequest alloc ] init ];
166- [requestQueue enqueue: closeRequest];
167- [requestQueue persistImmediately ];
168-
169- // Wait for operation to occur
170- [self awaitExpectations ];
171- [archiverMock verify ];
172- // [archiverMock stopMocking];
149+ @autoreleasepool {
150+ XCTestExpectation *expectation = [self expectationWithDescription: @" PersistExpectation" ];
151+
152+ id archiverMock = OCMClassMock ([NSKeyedArchiver class ]);
153+ [[archiverMock reject ] archiveRootObject: [OCMArg any ] toFile: [OCMArg any ]];
154+ [[[archiverMock expect ]
155+ andReturn: [NSData data ]]
156+ archivedDataWithRootObject: [OCMArg checkWithBlock: ^BOOL (NSArray *reqs) {
157+ if ([reqs isKindOfClass: [NSArray class ]]) {
158+ XCTAssert (reqs.count == 0 );
159+ BNCAfterSecondsPerformBlock (0.01 , ^{ [self safelyFulfillExpectation: expectation]; });
160+ return YES ;
161+ }
162+ return NO ;
163+ }]];
164+
165+ BNCServerRequestQueue *requestQueue = [[BNCServerRequestQueue alloc ] init ];
166+ BranchCloseRequest *closeRequest = [[BranchCloseRequest alloc ] init ];
167+ [requestQueue enqueue: closeRequest];
168+ [requestQueue persistImmediately ];
169+
170+ // Wait for operation to occur
171+ [self awaitExpectations ];
172+ [archiverMock verify ];
173+ BNCSleepForTimeInterval (0.001 ); // Allow for mock class to be un-mocked.
174+ }
173175}
174176
175177- (void )testDebugRequestsArentPersisted {
176-
177- XCTestExpectation *expectation = [self expectationWithDescription: @" PersistExpectation" ];
178- id archiverMock = OCMClassMock ([NSKeyedArchiver class ]);
179- [[archiverMock reject ] archiveRootObject: [OCMArg any ] toFile: [OCMArg any ]];
180- [[[archiverMock expect ]
181- andReturn: [NSData data ]]
182- archivedDataWithRootObject: [OCMArg checkWithBlock: ^BOOL (NSArray *reqs) {
183- if ([reqs isKindOfClass: [NSArray class ]]) {
184- XCTAssert (reqs.count == 0 );
185- BNCAfterSecondsPerformBlock (0.01 , ^{ [self safelyFulfillExpectation: expectation]; });
186- return YES ;
187- }
188- return NO ;
189- }]];
190-
191- BNCServerRequestQueue *requestQueue = [[BNCServerRequestQueue alloc ] init ];
192- [requestQueue persistImmediately ];
193-
194- // Wait for operation to occur
195- [self awaitExpectations ];
196- [archiverMock verify ];
197- // [archiverMock stopMocking];
178+ @autoreleasepool {
179+ XCTestExpectation *expectation = [self expectationWithDescription: @" PersistExpectation" ];
180+ id archiverMock = OCMClassMock ([NSKeyedArchiver class ]);
181+ [[archiverMock reject ] archiveRootObject: [OCMArg any ] toFile: [OCMArg any ]];
182+ [[[archiverMock expect ]
183+ andReturn: [NSData data ]]
184+ archivedDataWithRootObject: [OCMArg checkWithBlock: ^BOOL (NSArray *reqs) {
185+ if ([reqs isKindOfClass: [NSArray class ]]) {
186+ XCTAssert (reqs.count == 0 );
187+ BNCAfterSecondsPerformBlock (0.01 , ^{ [self safelyFulfillExpectation: expectation]; });
188+ return YES ;
189+ }
190+ return NO ;
191+ }]];
192+
193+ BNCServerRequestQueue *requestQueue = [[BNCServerRequestQueue alloc ] init ];
194+ [requestQueue persistImmediately ];
195+
196+ // Wait for operation to occur
197+ [self awaitExpectations ];
198+ [archiverMock verify ];
199+ BNCSleepForTimeInterval (0.001 ); // Allow for mock class to be un-mocked.
200+ }
198201}
199202
200203#pragma mark - Retrieve Tests
0 commit comments