Skip to content

Commit

Permalink
Add userId property to MockRemoteItem
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
  • Loading branch information
claucambra committed Nov 4, 2024
1 parent 33394ef commit f06c2c4
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Tests/Interface/MockRemoteInterface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public class MockRemoteInterface: RemoteInterface {
directory: true,
account: account.ncKitAccount,
username: account.username,
userId: account.id,
serverUrl: account.serverUrl
)
guard let parent = parentItem(path: remotePath) else {
Expand Down Expand Up @@ -185,6 +186,7 @@ public class MockRemoteInterface: RemoteInterface {
data: itemData,
account: account.ncKitAccount,
username: account.username,
userId: account.id,
serverUrl: account.serverUrl
)

Expand Down
6 changes: 5 additions & 1 deletion Tests/Interface/MockRemoteItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class MockRemoteItem: Equatable {
public var size: Int64 { Int64(data?.count ?? 0) }
public var account: String
public var username: String
public var userId: String
public var serverUrl: String
public var nkfile: NKFile {
let file = NKFile()
Expand All @@ -38,7 +39,7 @@ public class MockRemoteItem: Equatable {
file.serverUrl = parent?.remotePath ?? remotePath
file.account = account
file.user = username
file.userId = username
file.userId = userId
file.urlBase = serverUrl
file.lock = locked
file.lockOwner = lockOwner
Expand All @@ -62,6 +63,7 @@ public class MockRemoteItem: Equatable {
lhs.modificationDate == rhs.modificationDate &&
lhs.account == rhs.account &&
lhs.username == rhs.username &&
lhs.userId == rhs.userId &&
lhs.serverUrl == rhs.serverUrl
}

Expand All @@ -79,6 +81,7 @@ public class MockRemoteItem: Equatable {
lockTimeOut: Date? = nil,
account: String,
username: String,
userId: String,
serverUrl: String
) {
self.identifier = identifier
Expand All @@ -94,6 +97,7 @@ public class MockRemoteItem: Equatable {
self.lockTimeOut = lockTimeOut
self.account = account
self.username = username
self.userId = userId
self.serverUrl = serverUrl
}
}
20 changes: 20 additions & 0 deletions Tests/InterfaceTests/MockRemoteInterfaceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)

Expand All @@ -38,6 +39,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let itemB = MockRemoteItem(
Expand All @@ -48,6 +50,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let itemA_B = MockRemoteItem(
Expand All @@ -58,6 +61,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let targetItem = MockRemoteItem(
Expand All @@ -67,6 +71,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
remotePath: Self.account.davFilesUrl + "/a/b/target",
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)

Expand Down Expand Up @@ -166,6 +171,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let itemB = MockRemoteItem(
Expand All @@ -175,6 +181,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let itemC = MockRemoteItem(
Expand All @@ -184,6 +191,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let targetItem = MockRemoteItem(
Expand All @@ -192,6 +200,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
remotePath: Self.account.davFilesUrl + "/a/c/target",
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)

Expand Down Expand Up @@ -246,6 +255,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let itemB = MockRemoteItem(
Expand All @@ -255,6 +265,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let itemC = MockRemoteItem(
Expand All @@ -264,6 +275,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let itemA_A = MockRemoteItem(
Expand All @@ -273,6 +285,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let itemA_B = MockRemoteItem(
Expand All @@ -282,6 +295,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let itemC_A = MockRemoteItem(
Expand All @@ -291,6 +305,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let itemC_A_A = MockRemoteItem(
Expand All @@ -300,6 +315,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)

Expand Down Expand Up @@ -383,6 +399,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let itemB = MockRemoteItem(
Expand All @@ -392,6 +409,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let itemA_C = MockRemoteItem(
Expand All @@ -401,6 +419,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let itemA_C_D = MockRemoteItem(
Expand All @@ -409,6 +428,7 @@ final class MockRemoteInterfaceTests: XCTestCase {
remotePath: Self.account.davFilesUrl + "/a/c/d",
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)

Expand Down
5 changes: 5 additions & 0 deletions Tests/NextcloudFileProviderKitTests/EnumeratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ final class EnumeratorTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)

Expand All @@ -47,6 +48,7 @@ final class EnumeratorTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)

Expand All @@ -57,6 +59,7 @@ final class EnumeratorTests: XCTestCase {
remotePath: Self.account.davFilesUrl + "/folder/itemA",
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)

Expand All @@ -66,6 +69,7 @@ final class EnumeratorTests: XCTestCase {
remotePath: Self.account.davFilesUrl + "/folder/itemB",
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)

Expand All @@ -75,6 +79,7 @@ final class EnumeratorTests: XCTestCase {
remotePath: Self.account.davFilesUrl + "/folder/itemC",
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)

Expand Down
1 change: 1 addition & 0 deletions Tests/NextcloudFileProviderKitTests/ItemCreateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final class ItemCreateTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
static let dbManager = FilesDatabaseManager(realmConfig: .defaultConfiguration)
Expand Down
4 changes: 4 additions & 0 deletions Tests/NextcloudFileProviderKitTests/ItemDeleteTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ final class ItemDeleteTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
static let dbManager = FilesDatabaseManager(realmConfig: .defaultConfiguration)
Expand All @@ -45,6 +46,7 @@ final class ItemDeleteTests: XCTestCase {
remotePath: Self.account.davFilesUrl + "/file",
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
remoteItem.parent = rootItem
Expand Down Expand Up @@ -80,6 +82,7 @@ final class ItemDeleteTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let remoteItem = MockRemoteItem(
Expand All @@ -88,6 +91,7 @@ final class ItemDeleteTests: XCTestCase {
remotePath: Self.account.davFilesUrl + "/folder/file",
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
rootItem.children = [remoteFolder]
Expand Down
7 changes: 7 additions & 0 deletions Tests/NextcloudFileProviderKitTests/ItemFetchTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ final class ItemFetchTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
static let dbManager = FilesDatabaseManager(realmConfig: .defaultConfiguration)
Expand All @@ -47,6 +48,7 @@ final class ItemFetchTests: XCTestCase {
data: "Hello, World!".data(using: .utf8),
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
rootItem.children = [remoteItem]
Expand Down Expand Up @@ -102,6 +104,7 @@ final class ItemFetchTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let remoteDirectoryChildFile = MockRemoteItem(
Expand All @@ -112,6 +115,7 @@ final class ItemFetchTests: XCTestCase {
data: "Hello, World!".data(using: .utf8),
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let remoteDirectoryChildDirA = MockRemoteItem(
Expand All @@ -122,6 +126,7 @@ final class ItemFetchTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let remoteDirectoryChildDirB = MockRemoteItem(
Expand All @@ -132,6 +137,7 @@ final class ItemFetchTests: XCTestCase {
directory: true,
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
let remoteDirectoryChildDirBChildFile = MockRemoteItem(
Expand All @@ -142,6 +148,7 @@ final class ItemFetchTests: XCTestCase {
data: "Hello, World!".data(using: .utf8),
account: Self.account.ncKitAccount,
username: Self.account.username,
userId: Self.account.id,
serverUrl: Self.account.serverUrl
)
rootItem.children = [remoteDirectory]
Expand Down
Loading

0 comments on commit f06c2c4

Please sign in to comment.