diff --git a/src/interfaces/IFileSystem.sol b/src/interfaces/IFileSystem.sol index 0f053f5..5358e10 100644 --- a/src/interfaces/IFileSystem.sol +++ b/src/interfaces/IFileSystem.sol @@ -32,6 +32,9 @@ interface IFileSystem { */ error InodeNotFound(); + /** + * @notice Error thrown when file name is empty + */ error InvalidFileName(); /** diff --git a/test/FileSystem/CreateDirectory.sol b/test/FileSystem/CreateDirectory.sol index 5f19a37..54144a5 100644 --- a/test/FileSystem/CreateDirectory.sol +++ b/test/FileSystem/CreateDirectory.sol @@ -46,6 +46,12 @@ contract CreateDirectory is FileSystemTest { fileSystem.createDirectory(fileNames, filePointers); } + function test_RevertsWhen_FileNameEmpty() public { + fileNames[0] = ""; + vm.expectRevert(INVALID_FILENAME_ERROR); + fileSystem.createDirectory(fileNames, filePointers); + } + function test_RevertsWhen_InvalidCharacters() public { fileNames[0] = "/"; vm.expectRevert(INVALID_CHARACTER_ERROR); diff --git a/test/FileSystem/FileSystemTest.t.sol b/test/FileSystem/FileSystemTest.t.sol index 6fe15e4..6ba55ef 100644 --- a/test/FileSystem/FileSystemTest.t.sol +++ b/test/FileSystem/FileSystemTest.t.sol @@ -27,6 +27,7 @@ contract FileSystemTest is Test { bytes4 internal immutable FILE_NOT_FOUND_ERROR = IFileSystem.FileNotFound.selector; bytes4 internal immutable INODE_NOT_FOUND_ERROR = IFileSystem.InodeNotFound.selector; bytes4 internal immutable INVALID_CHARACTER_ERROR = IFileSystem.InvalidCharacter.selector; + bytes4 internal immutable INVALID_FILENAME_ERROR = IFileSystem.InvalidFileName.selector; bytes4 internal immutable LENGTH_MISMATCH_ERROR = IFileSystem.LengthMismatch.selector; function setUp() public virtual {