Skip to content

Commit c418948

Browse files
committed
Unit test changes
1 parent 97cffc6 commit c418948

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

Tests/Unit-Tests/NewRelicAgentTests/Uncategorized/NRLoggerTests.m

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -258,38 +258,26 @@ - (void) testRemoteLogLevels {
258258
#if !TARGET_OS_WATCH
259259
- (void) testAutoCollectedLogs {
260260
[NRMAFlags enableFeatures: NRFeatureFlag_RedirectStdOutStdErr];
261-
// Set the remote log level to Info.
261+
// Set the remote log level to debug.
262262
[NRLogger setRemoteLogLevel:NRLogLevelDebug];
263263
[NRAutoLogCollector redirectStandardOutputAndError];
264264

265-
XCTestExpectation *delayExpectation1 = [self expectationWithDescription:@"Waiting for Log Queue"];
266-
267-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
268-
[delayExpectation1 fulfill];
269-
});
270-
271-
[self waitForExpectationsWithTimeout:5 handler:^(NSError * _Nullable error) {
272-
if (error) {
273-
XCTFail(@"Timeout error");
274-
}
275-
}];
276-
277265
// Three messages should reach the remote log file for upload.
278-
NSLog(@"NSLog Test \n");
266+
NSLog(@"NSLog Test \n\n");
279267
os_log_t customLog = os_log_create("com.agent.tests", "logTest");
280268
// Log messages at different levels
281-
os_log(customLog, "This is a default os_log message.");
282-
os_log_info(customLog, "This is an info os_log message.");
283-
os_log_error(customLog, "This is an error os_log message.");
284-
os_log_fault(customLog, "This is a fault os_log message.");
269+
os_log(customLog, "This is a default os_log message.\n");
270+
os_log_info(customLog, "This is an info os_log message.\n");
271+
os_log_error(customLog, "This is an error os_log message.\n");
272+
os_log_fault(customLog, "This is a fault os_log message.\n");
285273

286274
XCTestExpectation *delayExpectation2 = [self expectationWithDescription:@"Waiting for Log Queue"];
287275

288-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
276+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
289277
[delayExpectation2 fulfill];
290278
});
291279

292-
[self waitForExpectationsWithTimeout:5 handler:^(NSError * _Nullable error) {
280+
[self waitForExpectationsWithTimeout:8 handler:^(NSError * _Nullable error) {
293281
if (error) {
294282
XCTFail(@"Timeout error");
295283
}
@@ -315,7 +303,7 @@ - (void) testAutoCollectedLogs {
315303
@{@"message": @"This is an error os_log message."},
316304
@{@"message": @"This is a fault os_log message."},
317305
];
318-
// check for existence of 6 logs.
306+
// check for existence of 5 logs.
319307
int foundCount = 0;
320308
// For each expected message.
321309
for (NSDictionary *dict in expectedValues) {

0 commit comments

Comments
 (0)