Skip to content

Commit

Permalink
Add test for moving trashed file out of the trash
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Dec 12, 2024
1 parent 87640de commit e0f7bac
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Tests/NextcloudFileProviderKitTests/ItemModifyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -863,4 +863,40 @@ final class ItemModifyTests: XCTestCase {
let untrashedItem = try XCTUnwrap(untrashedItemMaybe)
XCTAssertEqual(untrashedItem.parentItemIdentifier, .rootContainer)
}

func testMoveTrashedFileOutOfTrash() async throws {
let remoteInterface = MockRemoteInterface(rootItem: rootItem, rootTrashItem: rootTrashItem)

let trashItemMetadata = remoteTrashItem.toItemMetadata(account: Self.account)
Self.dbManager.addItemMetadata(trashItemMetadata)

let folderMetadata = remoteFolder.toItemMetadata(account: Self.account)
Self.dbManager.addItemMetadata(folderMetadata)

let trashItem = Item(
metadata: trashItemMetadata,
parentItemIdentifier: .trashContainer,
account: Self.account,
remoteInterface: remoteInterface
)
trashItem.dbManager = Self.dbManager

let untrashedTargetItem = Item(
metadata: trashItemMetadata,
parentItemIdentifier: .init(remoteFolder.identifier),
account: Self.account,
remoteInterface: remoteInterface
)

let (untrashedItemMaybe, untrashError) = await trashItem.modify(
itemTarget: untrashedTargetItem,
changedFields: [.parentItemIdentifier],
contents: nil,
dbManager: Self.dbManager
)
XCTAssertNil(untrashError)
let untrashedItem = try XCTUnwrap(untrashedItemMaybe)
untrashedItem.dbManager = Self.dbManager
XCTAssertEqual(untrashedItem.parentItemIdentifier, .init(remoteFolder.identifier))
}
}

0 comments on commit e0f7bac

Please sign in to comment.