Implemented the "delete(at: )" function for the FileService service in the module target.
This commit is contained in:
@@ -26,9 +26,34 @@ struct FileServiceTests {
|
||||
#expect(url == .someExistingFolder)
|
||||
#expect(url.isFileURL == true)
|
||||
}
|
||||
@Test(arguments: [URL.someNewFolder, .someNewFile])
|
||||
func delete(with url: URL) async throws {
|
||||
// GIVEN
|
||||
if try await !service.exists(at: url) {
|
||||
try await service.createFolder(at: url)
|
||||
}
|
||||
|
||||
// WHEN
|
||||
try await service.delete(at: url)
|
||||
|
||||
// THEN
|
||||
let result = try await service.exists(at: url)
|
||||
|
||||
#expect(result == false)
|
||||
}
|
||||
|
||||
@Test(arguments: zip([URL.someNonExistingFolder, .someNonExistingFile, .someRandomURL],
|
||||
[FileServiceError.urlNotExists, .urlNotExists, .urlNotFileURL]))
|
||||
func deleteThrows(
|
||||
with url: URL,
|
||||
expects error: FileServiceError
|
||||
) async throws {
|
||||
// GIVEN
|
||||
// WHEN
|
||||
// THEN
|
||||
await #expect(throws: error) {
|
||||
try await service.delete(at: url)
|
||||
}
|
||||
}
|
||||
|
||||
@Test(arguments: zip([URL.someExistingFolder, .someExistingFile, .someNonExistingFolder, .someNonExistingFile],
|
||||
@@ -62,7 +87,9 @@ struct FileServiceTests {
|
||||
|
||||
private extension URL {
|
||||
static let someExistingFolder = URL(at: "/private/tmp")
|
||||
static let someExistingFile = URL(at: "/etc/null")
|
||||
static let someExistingFile = URL(at: "/etc/ssh/ssh_config")
|
||||
static let someNewFolder = URL(at: "/private/tmp/folder")
|
||||
static let someNewFile = URL(at: "/private/tmp/file.ext")
|
||||
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")!
|
||||
|
||||
Reference in New Issue
Block a user