import Foundation import Testing @testable import ColibriLibrary struct FileServiceTests { // MARK: Properties private let service: FileServicing // MARK: Initialisers init() { self.service = FileService() } // MARK: Properties tests @Test func currentFolder() async { // GIVEN // WHEN let url = await service.currentFolder // THEN #expect(url == .someExistingFolder) #expect(url.isFileURL == true) } // GIVEN // WHEN // THEN } @Test(arguments: zip([URL.someExistingFolder, .someExistingFile, .someNonExistingFolder, .someNonExistingFile], [true, true, false, false])) func exists( with url: URL, expects outcome: Bool ) async throws { // GIVEN // WHEN let result = try await service.exists(at: url) // THEN #expect(result == outcome) } @Test func existsThrows() async throws { // GIVEN let url = URL.someRandomURL // WHEN // THEN await #expect(throws: FileServiceError.urlNotFileURL) { try await service.exists(at: url) } } } // MARK: - URL+Constants private extension URL { static let someExistingFolder = URL(at: "/private/tmp") static let someExistingFile = URL(at: "/etc/null") static let someNonExistingFolder = URL(at: "/some/random/folder") static let someNonExistingFile = URL(at: "/some/random/file.ext") static let someRandomURL = URL(string: "https://some.random.url")! }