Skip to content

Commit

Permalink
Update Litecore + misc (#3177)
Browse files Browse the repository at this point in the history
* update logs tests

* Core 3.2.0-83
  • Loading branch information
velicuvlad authored Aug 17, 2023
1 parent 13331a4 commit 0eeed68
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
3 changes: 1 addition & 2 deletions Objective-C/CBLQuery.mm
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,11 @@ - (NSString*) explain: (NSError**)outError {
}

- (nullable CBLQueryResultSet*) execute: (NSError**)outError {
C4QueryOptions options = kC4DefaultQueryOptions;

__block C4QueryEnumerator* e;
__block C4Error c4Err;
[self.database safeBlock:^{
e = c4query_run(_c4Query, &options, kC4SliceNull, &c4Err);
e = c4query_run(_c4Query, kC4SliceNull, &c4Err);
}];

if (!e) {
Expand Down
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
23 changes: 14 additions & 9 deletions Swift/Tests/LogTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ class LogTest: CBLTestCase {

let sfile = file as NSString
if sfile.range(of: "verbose").location != NSNotFound {
XCTAssertEqual(lineCount, 2)
} else if sfile.range(of: "info").location != NSNotFound {
XCTAssertEqual(lineCount, 3)
} else if sfile.range(of: "warning").location != NSNotFound {
} else if sfile.range(of: "info").location != NSNotFound {
XCTAssertEqual(lineCount, 4)
} else if sfile.range(of: "error").location != NSNotFound {
} else if sfile.range(of: "warning").location != NSNotFound {
XCTAssertEqual(lineCount, 5)
} else if sfile.range(of: "error").location != NSNotFound {
XCTAssertEqual(lineCount, 6)
}
}
}
Expand Down Expand Up @@ -352,12 +352,17 @@ class LogTest: CBLTestCase {
writeOneKiloByteOfLog()
for file in try getLogsInDirectory(config.directory) {
let contents = try String(contentsOf: file, encoding: .ascii)
guard let firstLine = contents.components(separatedBy: "\n").first else {
fatalError("log contents should be empty and needs header section")
let lines = contents.components(separatedBy: "\n")

// Check if the log file contains at least two lines
guard lines.count >= 2 else {
fatalError("log contents should have at least two lines: information and header section")
}
XCTAssert(firstLine.contains("CouchbaseLite/"))
XCTAssert(firstLine.contains("Build/"))
XCTAssert(firstLine.contains("Commit/"))
let secondLine = lines[1]

XCTAssert(secondLine.contains("CouchbaseLite/"))
XCTAssert(secondLine.contains("Build/"))
XCTAssert(secondLine.contains("Commit/"))
}
}

Expand Down
2 changes: 1 addition & 1 deletion vendor/couchbase-lite-core

0 comments on commit 0eeed68

Please sign in to comment.