Skip to content

Commit

Permalink
Set up standard trash state with an item in it in item modify tests
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
  • Loading branch information
claucambra committed Dec 12, 2024
1 parent 8c1b6bf commit ab16ae0
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions Tests/NextcloudFileProviderKitTests/ItemModifyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ final class ItemModifyTests: XCTestCase {

var remoteFolder: MockRemoteItem!
var remoteItem: MockRemoteItem!
var remoteTrashItem: MockRemoteItem!

static let dbManager = FilesDatabaseManager(realmConfig: .defaultConfiguration)

Expand Down Expand Up @@ -69,9 +70,21 @@ final class ItemModifyTests: XCTestCase {
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
remoteTrashItem = MockRemoteItem(
identifier: "trashItem",
versionIdentifier: "0",
name: "trashitem.txt (trashed)",
remotePath: Self.account.trashUrl + "/trashitem.txt (trashed)",
data: "Hello, World!".data(using: .utf8),
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl,
trashbinOriginalLocation: "folder/trashitem.txt"
)

rootItem.children = [remoteItem, remoteFolder]
rootTrashItem.children = []
rootTrashItem.children = [remoteTrashItem]
remoteItem.parent = rootItem
remoteFolder.parent = rootItem
}
Expand Down Expand Up @@ -540,8 +553,9 @@ final class ItemModifyTests: XCTestCase {
)
XCTAssertNil(error)

XCTAssertEqual(rootTrashItem.children.count, 1)
let remoteTrashedItem = rootTrashItem.children.first
XCTAssertEqual(rootTrashItem.children.count, 2)
let remoteTrashedItem =
rootTrashItem.children.first(where: { $0.identifier == itemMetadata.ocId })
XCTAssertNotNil(remoteTrashedItem)

let trashedItem = try XCTUnwrap(trashedItemMaybe)
Expand Down Expand Up @@ -602,8 +616,9 @@ final class ItemModifyTests: XCTestCase {
)
XCTAssertNil(error)

XCTAssertEqual(rootTrashItem.children.count, 1)
let remoteTrashedItem = rootTrashItem.children.first
XCTAssertEqual(rootTrashItem.children.count, 2)
let remoteTrashedItem =
rootTrashItem.children.first(where: { $0.identifier == itemMetadata.ocId})
XCTAssertNotNil(remoteTrashedItem)

let trashedItem = try XCTUnwrap(trashedItemMaybe)
Expand Down Expand Up @@ -679,8 +694,9 @@ final class ItemModifyTests: XCTestCase {
)
XCTAssertNil(error)

XCTAssertEqual(rootTrashItem.children.count, 1)
let remoteTrashedFolderItem = rootTrashItem.children.first
XCTAssertEqual(rootTrashItem.children.count, 2)
let remoteTrashedFolderItem =
rootTrashItem.children.first(where: { $0.identifier == folderMetadata.ocId })
XCTAssertNotNil(remoteTrashedFolderItem)

let trashedFolderItem = try XCTUnwrap(trashedFolderItemMaybe)
Expand Down Expand Up @@ -772,8 +788,9 @@ final class ItemModifyTests: XCTestCase {
)
XCTAssertNil(error)

XCTAssertEqual(rootTrashItem.children.count, 1)
let remoteTrashedFolderItem = rootTrashItem.children.first
XCTAssertEqual(rootTrashItem.children.count, 2)
let remoteTrashedFolderItem =
rootTrashItem.children.first(where: { $0.identifier == folderMetadata.ocId })
XCTAssertNotNil(remoteTrashedFolderItem)

let trashedFolderItem = try XCTUnwrap(trashedFolderItemMaybe)
Expand Down

0 comments on commit ab16ae0

Please sign in to comment.