Merge pull request #6627 from Bond-009/empty

Add regression test for #6560
pull/6629/head
Claus Vium 3 years ago committed by GitHub
commit fa506b1ff6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,7 +6,9 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoFixture; using AutoFixture;
using AutoFixture.AutoMoq; using AutoFixture.AutoMoq;
using Emby.Server.Implementations.Archiving;
using Emby.Server.Implementations.Updates; using Emby.Server.Implementations.Updates;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Updates; using MediaBrowser.Model.Updates;
using Moq; using Moq;
using Moq.Protected; using Moq.Protected;
@ -40,7 +42,9 @@ namespace Jellyfin.Server.Implementations.Tests.Updates
_fixture.Customize(new AutoMoqCustomization _fixture.Customize(new AutoMoqCustomization
{ {
ConfigureMembers = true ConfigureMembers = true
}).Inject(http); });
_fixture.Inject(http);
_fixture.Inject<IZipClient>(new ZipClient());
_installationManager = _fixture.Create<InstallationManager>(); _installationManager = _fixture.Create<InstallationManager>();
} }
@ -78,5 +82,32 @@ namespace Jellyfin.Server.Implementations.Tests.Updates
packages = _installationManager.FilterPackages(packages, id: new Guid("a4df60c5-6ab4-412a-8f79-2cab93fb2bc5")).ToArray(); packages = _installationManager.FilterPackages(packages, id: new Guid("a4df60c5-6ab4-412a-8f79-2cab93fb2bc5")).ToArray();
Assert.Single(packages); Assert.Single(packages);
} }
[Fact]
public async Task InstallPackage_InvalidChecksum_ThrowsInvalidDataException()
{
var packageInfo = new InstallationInfo()
{
Name = "Test",
SourceUrl = "https://repo.jellyfin.org/releases/plugin/empty/empty.zip",
Checksum = "InvalidChecksum"
};
await Assert.ThrowsAsync<InvalidDataException>(() => _installationManager.InstallPackage(packageInfo, CancellationToken.None)).ConfigureAwait(false);
}
[Fact]
public async Task InstallPackage_Valid_Success()
{
var packageInfo = new InstallationInfo()
{
Name = "Test",
SourceUrl = "https://repo.jellyfin.org/releases/plugin/empty/empty.zip",
Checksum = "11b5b2f1a9ebc4f66d6ef19018543361"
};
var ex = await Record.ExceptionAsync(() => _installationManager.InstallPackage(packageInfo, CancellationToken.None)).ConfigureAwait(false);
Assert.Null(ex);
}
} }
} }

Loading…
Cancel
Save