Skip to content

Commit

Permalink
update log test on obj-c
Browse files Browse the repository at this point in the history
  • Loading branch information
velicuvlad committed Aug 16, 2023
1 parent 0979614 commit 7067fdd
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Objective-C/Tests/LogTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ - (void) testFileLoggingLevels {
}];

if ([file rangeOfString: @"verbose"].location != NSNotFound)
AssertEqual(lineCount, 2);
else if ([file rangeOfString: @"info"].location != NSNotFound)
AssertEqual(lineCount, 3);
else if ([file rangeOfString: @"warning"].location != NSNotFound)
else if ([file rangeOfString: @"info"].location != NSNotFound)
AssertEqual(lineCount, 4);
else if ([file rangeOfString: @"error"].location != NSNotFound)
else if ([file rangeOfString: @"warning"].location != NSNotFound)
AssertEqual(lineCount, 5);
else if ([file rangeOfString: @"error"].location != NSNotFound)
AssertEqual(lineCount, 6);
}
}

Expand Down Expand Up @@ -379,11 +379,16 @@ - (void) testFileLoggingHeader {
NSString* contents = [NSString stringWithContentsOfURL: url
encoding: NSASCIIStringEncoding
error: &error];
AssertNil(error);
NSString* firstLine = [contents componentsSeparatedByString:@"\n"].firstObject;
Assert([firstLine rangeOfString: @"CouchbaseLite/"].location != NSNotFound);
Assert([firstLine rangeOfString: @"Build/"].location != NSNotFound);
Assert([firstLine rangeOfString: @"Commit/"].location != NSNotFound);
NSAssert(!error, @"Error reading file: %@", [error localizedDescription]);
NSArray<NSString *> *lines = [contents componentsSeparatedByString:@"\n"];

// Check if the log file contains at least two lines
NSAssert(lines.count >= 2, @"log contents should have at least two lines: information and header section");
NSString *secondLine = lines[1];

NSAssert([secondLine rangeOfString:@"CouchbaseLite/"].location != NSNotFound, @"Second line should contain 'CouchbaseLite/'");
NSAssert([secondLine rangeOfString:@"Build/"].location != NSNotFound, @"Second line should contain 'Build/'");
NSAssert([secondLine rangeOfString:@"Commit/"].location != NSNotFound, @"Second line should contain 'Commit/'");
}
}

Expand Down

0 comments on commit 7067fdd

Please sign in to comment.