Fixed: Add Unittest for DiskSpaceService irrelevant mounts

This commit is contained in:
Qstick 2017-10-29 00:42:03 -04:00
parent fe4499ee97
commit 25f08bd846
3 changed files with 24 additions and 4 deletions

View File

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
@ -51,7 +51,7 @@ namespace NzbDrone.Common.Disk
{ {
get get
{ {
if (VolumeLabel.IsNullOrWhiteSpace()) if (VolumeLabel.IsNullOrWhiteSpace() || VolumeLabel.StartsWith("UUID=") || Name == VolumeLabel)
{ {
return Name; return Name;
} }

View File

@ -99,5 +99,25 @@ namespace NzbDrone.Core.Test.DiskSpace
Mocker.GetMock<IDiskProvider>() Mocker.GetMock<IDiskProvider>()
.Verify(v => v.GetAvailableSpace(It.IsAny<string>()), Times.Never()); .Verify(v => v.GetAvailableSpace(It.IsAny<string>()), Times.Never());
} }
[TestCase("/boot")]
[TestCase("/var/lib/rancher")]
[TestCase("/var/lib/kubelet")]
[TestCase("/var/lib/docker")]
[TestCase("/some/place/docker/aufs")]
public void should_not_check_diskspace_for_irrelevant_mounts(string path)
{
var mount = new Mock<IMount>();
mount.SetupGet(v => v.RootDirectory).Returns(path);
mount.SetupGet(v => v.DriveType).Returns(System.IO.DriveType.Fixed);
Mocker.GetMock<IDiskProvider>()
.Setup(v => v.GetMounts())
.Returns(new List<IMount> { mount.Object });
var freeSpace = Subject.GetFreeSpace();
freeSpace.Should().BeEmpty();
}
} }
} }

View File

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using Mono.Unix; using Mono.Unix;
using NzbDrone.Common.Disk; using NzbDrone.Common.Disk;
@ -45,7 +45,7 @@ namespace NzbDrone.Mono.Disk
{ {
get get
{ {
if (VolumeLabel.IsNullOrWhiteSpace() || VolumeLabel.StartsWith("UUID=")) if (VolumeLabel.IsNullOrWhiteSpace() || VolumeLabel.StartsWith("UUID=") || Name == VolumeLabel)
{ {
return Name; return Name;
} }