unit testing

This commit is contained in:
2024-10-19 13:25:58 +01:00
parent 2b45e421dd
commit c615886a4c
22 changed files with 195 additions and 170 deletions

View File

@ -15,6 +15,7 @@ using NuGet.Protocol.Core.Types;
using isn.abst;
using NuGet.Common;
using System.Collections.Generic;
using NuGet.Versioning;
namespace isnd.host.tests
{
@ -58,7 +59,6 @@ namespace isnd.host.tests
}
[Fact]
public void NugetInstallsTest()
{
using (var serviceScope = server.Host.Services.CreateScope())
@ -83,7 +83,7 @@ namespace isnd.host.tests
using (var serviceScope = server.Host.Services.CreateScope())
{
var isnSettings = serviceScope.ServiceProvider.GetService<IOptions<isnd.Entities.IsndSettings>>().Value;
string pkgSourceUrl = isnSettings.ExternalUrl + apiindex;
string pkgSourceUrl = isnSettings.ExternalUrl + apiindex+ ".json";
NullThrottle throttle = new NullThrottle();
PackageSource packageSource = new PackageSource(pkgSourceUrl);
@ -99,7 +99,7 @@ namespace isnd.host.tests
using (var serviceScope = server.Host.Services.CreateScope())
{
var isnSettings = serviceScope.ServiceProvider.GetService<IOptions<isnd.Entities.IsndSettings>>().Value;
string pkgSourceUrl = isnSettings.ExternalUrl + apiindex;
string pkgSourceUrl = isnSettings.ExternalUrl + apiindex+ ".json";
var prov = new RegistrationResourceV3Provider();
var source = new PackageSource(pkgSourceUrl);
var repo = new SourceRepository(source, new INuGetResourceProvider[] { prov });
@ -137,7 +137,7 @@ namespace isnd.host.tests
Assert.NotEmpty(packages);
foreach (IPackageSearchMetadata package in packages)
foreach (var package in packages)
{
Console.WriteLine($"Version: {package.Identity.Version}");
Console.WriteLine($"Listed: {package.IsListed}");
@ -173,6 +173,7 @@ namespace isnd.host.tests
[Fact]
public async Task TestPackagePush()
{
server.EnsureUser(server.TestingUserName);
var logger = new TestLogger();
SourceRepository repository = Repository.Factory.GetCoreV3(SPIIndexURI);
PackageUpdateResource pushRes = await repository.GetResourceAsync<PackageUpdateResource>();
@ -183,13 +184,16 @@ namespace isnd.host.tests
}
[Fact]
public void TestDepedency()
// not yet from testing url a [Fact]
public async Task TestGetPackageUri()
{
PackageDependencyGroup g = new PackageDependencyGroup
{
TargetFramework="net7.0"
};
PackageSource source = new PackageSource("https://isn.pschneider.fr/v3/index.json");
source.ProtocolVersion=3;
SourceRepository repository = Repository.Factory.GetCoreV3(source);
string index = repository.ToJson();
PackageDetailsUriResourceV3 uriRes = await repository.GetResourceAsync<PackageDetailsUriResourceV3>();
Assert.NotNull(uriRes);// package details Uri Resource
Uri u = uriRes.GetUri("isn.abst", new NuGetVersion("1.0.24"));
}
private string GetSymbolsApiKey(string apiUrl)