From e1320ad3823f917d4eb40638a4025f96bf9312ae Mon Sep 17 00:00:00 2001 From: Milen Pivchev Date: Tue, 1 Jul 2025 13:04:13 +0200 Subject: [PATCH] New name validator tests Signed-off-by: Milen Pivchev --- .../FileNameValidatorUnitTests.swift | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Tests/NextcloudKitUnitTests/FileNameValidatorUnitTests.swift b/Tests/NextcloudKitUnitTests/FileNameValidatorUnitTests.swift index 7828c27a..287bc306 100644 --- a/Tests/NextcloudKitUnitTests/FileNameValidatorUnitTests.swift +++ b/Tests/NextcloudKitUnitTests/FileNameValidatorUnitTests.swift @@ -101,6 +101,31 @@ class FileNameValidatorUnitTests: XCTestCase { func testFilePathWithNestedFolder() { let folderPath = "validFolder/secondValidFolder/CON" + let filePaths = ["file1.txt", "file2.doc", "file3."] + + let result = fileNameValidator.checkFolderPath(folderPath) + XCTAssertFalse(result) + + filePaths.forEach { path in + let result = fileNameValidator.checkFileName(path) + + if path == "file3." { + XCTAssertNotNil(result?.errorDescription) + } else { + XCTAssertNil(result?.errorDescription) + } + } + } + + func testOnlyFolderPath() { + let folderPath = "/A1/Aaaww/W/C2/" + + let result = fileNameValidator.checkFolderPath(folderPath) + XCTAssertTrue(result) + } + + func testOnlyFolderPathWithOneReservedName() { + let folderPath = "/A1/Aaaww/CON/W/C2/" let result = fileNameValidator.checkFolderPath(folderPath) XCTAssertFalse(result)