mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 14:11:10 +00:00
Allows renaming files that are not executable on Unix
This commit is contained in:
1 parent
114bfe94ff
commit
f14b321294
2 files changed
+1
-31
No files matched your search
-28
@@ -700,7 +700,6 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.FileInfo.New(path.Path).Returns(fileInfo);
|
||||
_mockFileSystem.Path.Combine(parentPath, newName).Returns(newPath);
|
||||
_mockFileSystemPermissionsService.CanAccessPath(Arg.Any<FileSystemPathId>(), FileAccessMode.Write).Returns(true);
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.Execute).Returns(true);
|
||||
|
||||
// Act
|
||||
Result<FileSystemPathId> result = _sut.RenameFile(path, newName);
|
||||
@@ -737,33 +736,6 @@ public class FileProviderServiceTests
|
||||
_mockFileSystem.File.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RenameFile_WhenFileIsNotExecutable_ShouldReturnUnauthorizedAccessError()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(
|
||||
s_isUnix ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
);
|
||||
string newName = "NewName.txt";
|
||||
string parentPath = s_isUnix ? "/" : @"C:\";
|
||||
string newPath = s_isUnix ? "/NewName.txt" : @"C:\NewName.txt";
|
||||
|
||||
IFileInfo fileInfo = Substitute.For<IFileInfo>();
|
||||
fileInfo.DirectoryName.Returns(parentPath);
|
||||
_mockFileSystem.FileInfo.New(path.Path).Returns(fileInfo);
|
||||
_mockFileSystem.Path.Combine(parentPath, newName).Returns(newPath);
|
||||
_mockFileSystemPermissionsService.CanAccessPath(Arg.Any<FileSystemPathId>(), FileAccessMode.Write).Returns(true);
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.Execute).Returns(false);
|
||||
|
||||
// Act
|
||||
Result<FileSystemPathId> result = _sut.RenameFile(path, newName);
|
||||
|
||||
// Assert
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.Permission.UnauthorizedAccess, result.FirstError);
|
||||
_mockFileSystem.File.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RenameFile_WhenParentDirectoryIsNull_ShouldReturnInvalidPathError()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user