Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test: add integration tests for improved git error messages
Co-authored-by: alirezanet <7004080+alirezanet@users.noreply.github.com>
  • Loading branch information
Copilot and alirezanet committed Mar 12, 2026
commit e3c48f0c0a0790b9d514e8268c7f10284d26c86d
46 changes: 46 additions & 0 deletions tests/HuskyIntegrationTests/GitErrorMessageTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using FluentAssertions;

namespace HuskyIntegrationTests;

/// <summary>
/// Integration tests that verify the error messages shown when git is unavailable
/// or when Husky has not been installed (dotnet husky install was not run).
/// </summary>
public class GitErrorMessageTests(ITestOutputHelper output)
{
[Fact]
public async Task HuskyRun_WhenHuskyIsNotInstalled_ShouldShowInstallHintInErrorMessage()
{
// arrange: set up git and husky tool WITHOUT running dotnet husky install
await using var c = await DockerHelper.StartContainerAsync();
await c.BashAsync("dotnet new tool-manifest");
await c.BashAsync("dotnet tool install --no-cache --add-source /app/nupkg/ husky --version 99.1.1-test");
await c.BashAsync("dotnet tool restore");
await c.BashAsync("git init");
// Intentionally NOT running: dotnet husky install

// act
var result = await c.BashAsync(output, "dotnet husky run");

// assert
result.ExitCode.Should().NotBe(0);
result.Stderr.Should().Contain("dotnet husky install");
}

[Fact]
public async Task HuskyRun_WhenGitIsNotAvailable_ShouldShowHelpfulErrorMessage()
{
// arrange: fully install husky, then remove the git binary from PATH to simulate it being missing
await using var c = await DockerHelper.StartWithInstalledHusky();
await c.BashAsync("mv $(which git) /tmp/git_backup");

// act
var result = await c.BashAsync(output, "dotnet husky run");

// assert
result.ExitCode.Should().NotBe(0);
var allOutput = result.Stdout + result.Stderr;
allOutput.Should().Contain("not found");
allOutput.Should().Contain("PATH");
}
}
Loading