public async Task Test_NpmRepository_Test_Prerelease_Packages() { var sourcePackages = await SourceRepo.ListAsync(null, true, false) .ToListAsync(); Assert.True(sourcePackages.Count > 0); }
public async Task Test_NpmRepository_Delete_Single_Package_Version_Without_Deleting_Other_Versions() { // Exclusively use the express package from this test var sourcePackages = await SourceRepo.ListAsync(null, true, false) .Where(p => p.Id.Equals("@types/express")) .ToListAsync(); // Copy the packages from the source feed to the target feed foreach (var package in sourcePackages) { var p = await SourceRepo.FetchAsync(package.Id, package.Version); await TargetRepo.AddAsync(p); } var targetPackages = await TargetRepo.ListAsync(null, true, false) .Where(p => p.Id.StartsWith("@types/express")) .ToListAsync(); try { Assert.True(targetPackages.Count > 1); var counter = 0; foreach (var targetPackage in targetPackages) { await TargetRepo.DeleteAsync(targetPackage.Id, targetPackage.Version); var remainingPackages = await TargetRepo.ListAsync(null, true, false) .Where(p => p.Id.StartsWith("@types/express")) .ToListAsync(); counter++; Assert.True(remainingPackages.Count == (targetPackages.Count - counter)); } } finally { // Only delete the packages that were added from the source foreach (var targetPackage in sourcePackages) { await TargetRepo.DeleteAsync(targetPackage.Id, targetPackage.Version); } } }
public async Task Test_NpmRepository_Copy_And_Delete_Packages() { // Exclude the express package from this test because it is used in another test var sourcePackages = await SourceRepo.ListAsync(null, true, false) .Where(p => !p.Id.Equals("@types/express", StringComparison.Ordinal)) .ToListAsync(); var targetPackages = await TargetRepo.ListAsync(null, true, false) .Where(p => !p.Id.Equals("@types/express", StringComparison.Ordinal)) .ToListAsync(); var targetPackagesCountBefore = targetPackages.Count; foreach (var package in sourcePackages) { var p = await SourceRepo.FetchAsync(package.Id, package.Version); await TargetRepo.AddAsync(p); } targetPackages = await TargetRepo.ListAsync(null, true, false).ToListAsync(); try { Assert.True(targetPackages.Count > targetPackagesCountBefore); } finally { // Only delete the packages that were added from the source foreach (var targetPackage in sourcePackages) { await TargetRepo.DeleteAsync(targetPackage.Id, targetPackage.Version); } } targetPackages = await TargetRepo.ListAsync(null, true, false) .Where(p => !p.Id.Equals("@types/express", StringComparison.Ordinal)) .ToListAsync(); Assert.Equal(targetPackages.Count, targetPackagesCountBefore); }