fix tests. new product advisories enhancements
This commit is contained in:
@@ -65,8 +65,7 @@ try
|
||||
|
||||
foreach (var entry in response.S3Objects)
|
||||
{
|
||||
if (entry.Size == 0 && entry.Key.EndsWith("/", StringComparison.Ordinal))
|
||||
{
|
||||
if (entry.Size == 0 && entry.Key.EndsWith('/')) {
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
@@ -231,11 +230,8 @@ static bool ShouldRetry(HttpStatusCode statusCode)
|
||||
|| statusCode == (HttpStatusCode)429
|
||||
|| (int)statusCode >= 500;
|
||||
|
||||
internal sealed class RetryableException : Exception
|
||||
internal sealed class RetryableException(string message) : Exception(message)
|
||||
{
|
||||
public RetryableException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed record MigrationOptions
|
||||
|
||||
@@ -22,13 +22,15 @@ public sealed class DiffPipelineServiceTests
|
||||
filePath: "original",
|
||||
fileHash: metadata.Original.Sha256,
|
||||
new SectionHashEntry { Name = ".text", Sha256 = "1111", Size = 100 },
|
||||
new SectionHashEntry { Name = ".rodata", Sha256 = "2222", Size = 50 });
|
||||
new SectionHashEntry { Name = ".rodata", Sha256 = "2222", Size = 50 },
|
||||
new SectionHashEntry { Name = ".data", Sha256 = "4444", Size = 30 });
|
||||
|
||||
var patchedSections = TestData.CreateSectionHashSet(
|
||||
filePath: "patched",
|
||||
fileHash: metadata.Patched.Sha256,
|
||||
new SectionHashEntry { Name = ".text", Sha256 = "3333", Size = 110 },
|
||||
new SectionHashEntry { Name = ".rodata", Sha256 = "2222", Size = 50 });
|
||||
new SectionHashEntry { Name = ".rodata", Sha256 = "2222", Size = 50 },
|
||||
new SectionHashEntry { Name = ".data", Sha256 = "4444", Size = 30 });
|
||||
|
||||
await File.WriteAllTextAsync(layout.GetOriginalSectionHashPath(metadata), GoldenPairsJsonSerializer.Serialize(originalSections));
|
||||
await File.WriteAllTextAsync(layout.GetPatchedSectionHashPath(metadata), GoldenPairsJsonSerializer.Serialize(patchedSections));
|
||||
@@ -38,7 +40,7 @@ public sealed class DiffPipelineServiceTests
|
||||
|
||||
report.Verdict.Should().Be(GoldenDiffVerdict.Patched);
|
||||
report.MatchesExpected.Should().BeTrue();
|
||||
report.Sections.Should().HaveCount(2);
|
||||
report.Sections.Should().HaveCount(3);
|
||||
report.Sections.First(section => section.Name == ".text").Status.Should().Be(SectionComparisonStatus.Modified);
|
||||
report.Sections.First(section => section.Name == ".rodata").Status.Should().Be(SectionComparisonStatus.Identical);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,10 @@ public sealed class PackageMirrorServiceTests
|
||||
var sourcePath = Path.Combine(temp.Path, "source.bin");
|
||||
await File.WriteAllTextAsync(sourcePath, "payload");
|
||||
|
||||
// Create a destination subdirectory to avoid same-file copy issues
|
||||
var destDir = Path.Combine(temp.Path, "dest");
|
||||
Directory.CreateDirectory(destDir);
|
||||
|
||||
var sha256 = ComputeSha256(sourcePath);
|
||||
var artifact = new BinaryArtifact
|
||||
{
|
||||
@@ -26,12 +30,13 @@ public sealed class PackageMirrorServiceTests
|
||||
Source = new Uri(sourcePath).AbsoluteUri,
|
||||
Sha256 = sha256,
|
||||
HasDebugSymbols = false
|
||||
// Note: PathInPackage is left null to test simple file copy (not deb extraction)
|
||||
};
|
||||
|
||||
var mirror = new AptPackageMirrorService(new NoHttpClientFactory(), NullLogger<AptPackageMirrorService>.Instance);
|
||||
var result = await mirror.FetchAsync(artifact, temp.Path);
|
||||
var result = await mirror.FetchAsync(artifact, destDir);
|
||||
|
||||
result.Success.Should().BeTrue();
|
||||
result.Success.Should().BeTrue($"Fetch failed: {result.ErrorMessage}");
|
||||
result.HashMatches.Should().BeTrue();
|
||||
File.Exists(result.LocalPath).Should().BeTrue();
|
||||
}
|
||||
@@ -43,6 +48,10 @@ public sealed class PackageMirrorServiceTests
|
||||
var sourcePath = Path.Combine(temp.Path, "source.bin");
|
||||
await File.WriteAllTextAsync(sourcePath, "payload");
|
||||
|
||||
// Create a destination subdirectory to avoid same-file copy issues
|
||||
var destDir = Path.Combine(temp.Path, "dest");
|
||||
Directory.CreateDirectory(destDir);
|
||||
|
||||
var artifact = new BinaryArtifact
|
||||
{
|
||||
Package = "test",
|
||||
@@ -51,10 +60,11 @@ public sealed class PackageMirrorServiceTests
|
||||
Source = new Uri(sourcePath).AbsoluteUri,
|
||||
Sha256 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
HasDebugSymbols = false
|
||||
// Note: PathInPackage is left null to test simple file copy (not deb extraction)
|
||||
};
|
||||
|
||||
var mirror = new AptPackageMirrorService(new NoHttpClientFactory(), NullLogger<AptPackageMirrorService>.Instance);
|
||||
var result = await mirror.FetchAsync(artifact, temp.Path);
|
||||
var result = await mirror.FetchAsync(artifact, destDir);
|
||||
|
||||
result.Success.Should().BeFalse();
|
||||
result.HashMatches.Should().BeFalse();
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentAssertions" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||
<PackageReference Include="xunit" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user