mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Fix logging when running unit tests
This commit is contained in:
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
||||
shell: pwsh
|
||||
run: .\pack.ps1
|
||||
- name: Test
|
||||
run: dotnet test test\Squirrel.Tests.csproj --verbosity normal
|
||||
run: dotnet test test\Squirrel.Tests.csproj -l "console;verbosity=detailed"
|
||||
- name: "Upload Tools"
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
|
||||
@@ -8,15 +8,18 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Squirrel.NuGet;
|
||||
using Squirrel.SimpleSplat;
|
||||
using Squirrel;
|
||||
using Squirrel.Tests.TestHelpers;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Squirrel.Tests
|
||||
{
|
||||
public class ApplyReleasesTests : IEnableLogger
|
||||
public class ApplyReleasesTests : TestLoggingBase
|
||||
{
|
||||
public ApplyReleasesTests(ITestOutputHelper log) : base(log)
|
||||
{
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CleanInstallRunsSquirrelAwareAppsWithInstallFlag()
|
||||
{
|
||||
|
||||
@@ -7,11 +7,16 @@ using Squirrel;
|
||||
using Squirrel.SimpleSplat;
|
||||
using Squirrel.Tests.TestHelpers;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Squirrel.Tests
|
||||
{
|
||||
public class ApplyDeltaPackageTests : IEnableLogger
|
||||
public class ApplyDeltaPackageTests : TestLoggingBase
|
||||
{
|
||||
public ApplyDeltaPackageTests(ITestOutputHelper log) : base(log)
|
||||
{
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ApplyDeltaPackageSmokeTest()
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ using Xunit;
|
||||
|
||||
namespace Squirrel.Tests
|
||||
{
|
||||
public class DownloadReleasesTests : IEnableLogger
|
||||
public class DownloadReleasesTests
|
||||
{
|
||||
[Fact(Skip = "Rewrite this to be an integration test")]
|
||||
public void ChecksumShouldFailIfFilesAreMissing()
|
||||
|
||||
@@ -11,11 +11,16 @@ using System.Xml.Linq;
|
||||
using Squirrel.SimpleSplat;
|
||||
using Xunit;
|
||||
using Squirrel.NuGet;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Squirrel.Tests
|
||||
{
|
||||
public class CreateReleasePackageTests : IEnableLogger
|
||||
public class CreateReleasePackageTests : TestLoggingBase
|
||||
{
|
||||
public CreateReleasePackageTests(ITestOutputHelper log) : base(log)
|
||||
{
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("1.2.3")]
|
||||
[InlineData("1.2.3-alpha13")]
|
||||
|
||||
49
test/TestHelpers/Logging.cs
Normal file
49
test/TestHelpers/Logging.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Squirrel.SimpleSplat;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Squirrel.Tests
|
||||
{
|
||||
public interface ITestLogging
|
||||
{
|
||||
IFullLogger Log();
|
||||
}
|
||||
|
||||
public class TestLogger : ILogger
|
||||
{
|
||||
public LogLevel Level { get; set; }
|
||||
public ITestOutputHelper OutputHelper { get; }
|
||||
|
||||
public TestLogger(ITestOutputHelper outputHelper)
|
||||
{
|
||||
OutputHelper = outputHelper;
|
||||
}
|
||||
|
||||
public void Write([Localizable(false)] string message, LogLevel logLevel)
|
||||
{
|
||||
OutputHelper.WriteLine(message);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class TestLoggingBase : ITestLogging
|
||||
{
|
||||
public ITestOutputHelper OutputHelper { get; }
|
||||
public IFullLogger Logger { get; }
|
||||
|
||||
public TestLoggingBase(ITestOutputHelper log)
|
||||
{
|
||||
OutputHelper = log;
|
||||
Logger = new WrappingFullLogger(new TestLogger(OutputHelper), typeof(TestLogger));
|
||||
}
|
||||
|
||||
public IFullLogger Log()
|
||||
{
|
||||
return Logger;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,16 @@ using Squirrel.Tests.TestHelpers;
|
||||
using Xunit;
|
||||
using Squirrel.Shell;
|
||||
using System.Collections.Generic;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Squirrel.Tests
|
||||
{
|
||||
public class UtilityTests : IEnableLogger
|
||||
public class UtilityTests : TestLoggingBase
|
||||
{
|
||||
public UtilityTests(ITestOutputHelper log) : base(log)
|
||||
{
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("file.txt", "file.txt")]
|
||||
[InlineData("file", "file")]
|
||||
|
||||
Reference in New Issue
Block a user