Skip to content

Commit

Permalink
Test for proper handling of trashed folder child items when restoring…
Browse files Browse the repository at this point in the history
… trashed folder

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
  • Loading branch information
claucambra committed Dec 13, 2024
1 parent bf5a671 commit 216016d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Tests/NextcloudFileProviderKitTests/ItemModifyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,10 @@ final class ItemModifyTests: XCTestCase {
let trashFolderMetadata = remoteTrashFolder.toItemMetadata(account: Self.account)
Self.dbManager.addItemMetadata(trashFolderMetadata)

let trashFolderChildItemMetadata =
remoteTrashFolderChildItem.toItemMetadata(account: Self.account)
Self.dbManager.addItemMetadata(trashFolderChildItemMetadata)

let trashedFolderItem = Item(
metadata: trashFolderMetadata,
parentItemIdentifier: .trashContainer,
Expand All @@ -1140,5 +1144,17 @@ final class ItemModifyTests: XCTestCase {
let untrashedItem = try XCTUnwrap(untrashedFolderItemMaybe)
untrashedItem.dbManager = Self.dbManager
XCTAssertEqual(untrashedItem.parentItemIdentifier, .rootContainer)
XCTAssertEqual(remoteTrashFolder.children.count, 1)
XCTAssertTrue(remoteTrashFolder.remotePath.hasPrefix(Self.account.davFilesUrl))

let untrashedFolderChildItemMaybe =
Self.dbManager.itemMetadataFromOcId(remoteTrashFolderChildItem.identifier)
let untrashedFolderChildItem = try XCTUnwrap(untrashedFolderChildItemMaybe)
XCTAssertEqual(remoteTrashFolder.children.first?.identifier, untrashedFolderChildItem.ocId)
XCTAssertEqual(
remoteTrashFolderChildItem.remotePath,
remoteTrashFolder.remotePath + "/" + remoteTrashFolderChildItem.name
)
XCTAssertEqual(untrashedFolderChildItem.serverUrl, remoteTrashFolder.remotePath)
}
}

0 comments on commit 216016d

Please sign in to comment.