49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
|
|
// Copyright (c) The Geekeey Authors
|
||
|
|
// SPDX-License-Identifier: EUPL-1.2
|
||
|
|
|
||
|
|
using System.Diagnostics;
|
||
|
|
using System.IO.Compression;
|
||
|
|
|
||
|
|
namespace Geekeey.Request.Tests;
|
||
|
|
|
||
|
|
internal sealed class PackageContentsTests
|
||
|
|
{
|
||
|
|
private static string RepoRoot => Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..");
|
||
|
|
private static string ArtifactsDir => Path.Combine(RepoRoot, "artifacts");
|
||
|
|
private static string ProjectPath => Path.Combine(RepoRoot, "src", "request.dispatcher", "Geekeey.Request.Dispatcher.csproj");
|
||
|
|
|
||
|
|
private readonly string _outputDir;
|
||
|
|
|
||
|
|
public PackageContentsTests()
|
||
|
|
{
|
||
|
|
_outputDir = Path.Combine(ArtifactsDir, Path.GetRandomFileName());
|
||
|
|
}
|
||
|
|
|
||
|
|
[Before(Test)]
|
||
|
|
public async Task SetUpAsync()
|
||
|
|
{
|
||
|
|
Directory.CreateDirectory(_outputDir);
|
||
|
|
}
|
||
|
|
|
||
|
|
[After(Test)]
|
||
|
|
public async Task CleanUpAsync()
|
||
|
|
{
|
||
|
|
Directory.Delete(_outputDir, true);
|
||
|
|
}
|
||
|
|
|
||
|
|
[Test]
|
||
|
|
public async Task I_can_verify_the_package_contains_the_expected_contents()
|
||
|
|
{
|
||
|
|
using var process = Process.Start("dotnet", $"pack \"{ProjectPath}\" -o \"{_outputDir}\" -c Release");
|
||
|
|
await process.WaitForExitAsync();
|
||
|
|
|
||
|
|
var pkgs = Directory.GetFiles(_outputDir, "*.nupkg");
|
||
|
|
await Assert.That(pkgs.Length).IsGreaterThanOrEqualTo(1);
|
||
|
|
|
||
|
|
await using var archive = await ZipFile.OpenReadAsync(pkgs[0]);
|
||
|
|
var entries = archive.Entries.Select(entry => entry.FullName.Replace('\\', '/')).ToHashSet();
|
||
|
|
|
||
|
|
await Assert.That(entries).Contains("lib/net10.0/Geekeey.Request.Dispatcher.dll");
|
||
|
|
await Assert.That(entries).Contains("lib/net10.0/Geekeey.Request.Dispatcher.xml");
|
||
|
|
}
|
||
|
|
}
|