You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-ios/_SharedTestUtilities/MockFileManager.swift

40 lines
1.6 KiB
Swift

// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
import Foundation
import SessionUtilitiesKit
class MockFileManager: Mock<FileManagerType>, FileManagerType {
var currentDirectoryPath: String { mock() }
func urls(for directory: FileManager.SearchPathDirectory, in domains: FileManager.SearchPathDomainMask) -> [URL] {
return mock(args: [directory, domains])
}
func containerURL(forSecurityApplicationGroupIdentifier: String) -> URL? {
return mock(args: [forSecurityApplicationGroupIdentifier])
}
func enumerator(
at url: URL,
includingPropertiesForKeys: [URLResourceKey]?,
options: FileManager.DirectoryEnumerationOptions,
errorHandler: ((URL, Error) -> Bool)?
) -> FileManager.DirectoryEnumerator? {
return mock(args: [url, includingPropertiesForKeys, options, errorHandler])
}
func fileExists(atPath: String) -> Bool { return mock(args: [atPath]) }
func contents(atPath: String) -> Data? { return mock(args: [atPath]) }
func createFile(atPath: String, contents: Data?, attributes: [FileAttributeKey : Any]?) -> Bool {
return mock(args: [atPath, contents, attributes])
}
func createDirectory(atPath: String, withIntermediateDirectories: Bool, attributes: [FileAttributeKey : Any]?) throws {
return try mockThrowing(args: [atPath, withIntermediateDirectories, attributes])
}
func copyItem(at fromUrl: URL, to toUrl: URL) throws { return try mockThrowing(args: [fromUrl, toUrl]) }
func removeItem(atPath: String) throws { return try mockThrowing(args: [atPath]) }
}