Fix GetBestRootFolderPath tests
This commit is contained in:
parent
5f72178445
commit
63a911a9a5
|
@ -1,8 +1,6 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Moq;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common.Disk;
|
|
||||||
using NzbDrone.Core.RootFolders;
|
using NzbDrone.Core.RootFolders;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
@ -34,15 +32,34 @@ namespace NzbDrone.Core.Test.RootFolderTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_get_parent_path_from_diskProvider_if_matching_root_folder_is_not_found()
|
public void should_get_parent_path_from_os_path_if_matching_root_folder_is_not_found()
|
||||||
{
|
{
|
||||||
var seriesPath = @"T:\Test\TV\Series Title".AsOsAgnostic();
|
var seriesPath = @"T:\Test\TV\Series Title".AsOsAgnostic();
|
||||||
|
|
||||||
GivenRootFolders(@"C:\Test\TV".AsOsAgnostic(), @"D:\Test\TV".AsOsAgnostic());
|
GivenRootFolders(@"C:\Test\TV".AsOsAgnostic(), @"D:\Test\TV".AsOsAgnostic());
|
||||||
Subject.GetBestRootFolderPath(seriesPath);
|
Subject.GetBestRootFolderPath(seriesPath).Should().Be(@"T:\Test\TV".AsOsAgnostic());
|
||||||
|
}
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
[Test]
|
||||||
.Verify(v => v.GetParentFolder(seriesPath), Times.Once);
|
public void should_get_parent_path_from_os_path_if_matching_root_folder_is_not_found_for_posix_path()
|
||||||
|
{
|
||||||
|
WindowsOnly();
|
||||||
|
|
||||||
|
var seriesPath = "/mnt/tv/Series Title";
|
||||||
|
|
||||||
|
GivenRootFolders(@"C:\Test\TV".AsOsAgnostic(), @"D:\Test\TV".AsOsAgnostic());
|
||||||
|
Subject.GetBestRootFolderPath(seriesPath).Should().Be(@"/mnt/tv".AsOsAgnostic());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_get_parent_path_from_os_path_if_matching_root_folder_is_not_found_for_windows_path()
|
||||||
|
{
|
||||||
|
PosixOnly();
|
||||||
|
|
||||||
|
var seriesPath = @"T:\Test\TV\Series Title";
|
||||||
|
|
||||||
|
GivenRootFolders(@"C:\Test\TV".AsOsAgnostic(), @"D:\Test\TV".AsOsAgnostic());
|
||||||
|
Subject.GetBestRootFolderPath(seriesPath).Should().Be(@"T:\Test\TV".AsOsAgnostic());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ namespace NzbDrone.Core.RootFolders
|
||||||
{
|
{
|
||||||
var osPath = new OsPath(path);
|
var osPath = new OsPath(path);
|
||||||
|
|
||||||
return osPath.Directory.ToString();
|
return osPath.Directory.ToString().TrimEnd(osPath.IsUnixPath ? '/' : '\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
return possibleRootFolder?.Path;
|
return possibleRootFolder?.Path;
|
||||||
|
|
Loading…
Reference in New Issue