Skip to content

Commit 057907b

Browse files
i2h3claude
authored andcommitted
fix(file-provider): Fix flaky testEnumerate root date assertion
MockRemoteInterfaceTests.testEnumerate compared the enumerated root file's date against the item's creationDate, but toNKFile() maps modificationDate onto NKFile.date. MockRemoteItem defaults creationDate and modificationDate to two separate Date() calls that are only sometimes identical, so the assertion flaked on CI when the clock ticked between them. Compare against modificationDate, the field the value is actually derived from. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Iva Horn <iva.horn@nextcloud.com>
1 parent c1909a3 commit 057907b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

shell_integration/MacOSX/NextcloudFileProviderKit/Tests/InterfaceTests/MockRemoteInterfaceTests.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,12 @@ final class MockRemoteInterfaceTests: XCTestCase {
503503
XCTAssertEqual(targetRootFile?.ocId, expectedRoot?.identifier)
504504
XCTAssertEqual(targetRootFile?.fileName, NextcloudKit.shared.nkCommonInstance.rootFileName) // NextcloudKit gives the root dir this name
505505
XCTAssertEqual(targetRootFile?.serverUrl, "https://mock.nc.com/remote.php/dav/files/testUserId") // NextcloudKit gives the root dir this url
506-
XCTAssertEqual(targetRootFile?.date, expectedRoot?.creationDate)
506+
// `toNKFile()` maps the item's `modificationDate` onto `NKFile.date`, so compare against
507+
// that — not `creationDate`. `MockRemoteItem.init` defaults `creationDate` and
508+
// `modificationDate` to two separate `Date()` calls, which are usually (but not always)
509+
// identical; comparing `date` to `creationDate` therefore passed only when the clock did
510+
// not tick between those two calls, and flaked on CI when it did.
511+
XCTAssertEqual(targetRootFile?.date, expectedRoot?.modificationDate)
507512
XCTAssertEqual(targetRootFile?.etag, expectedRoot?.versionIdentifier)
508513

509514
let resultChildren = await remoteInterface.enumerate(

0 commit comments

Comments
 (0)