Fixed: Add Unittest for DiskSpaceService irrelevant mounts

pull/110/head
Qstick 7 years ago
parent fe4499ee97
commit 25f08bd846

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

@ -99,5 +99,25 @@ namespace NzbDrone.Core.Test.DiskSpace
Mocker.GetMock<IDiskProvider>()
.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();
}
}
}

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

Loading…
Cancel
Save