Skip to content

Commit

Permalink
fix: compile error
Browse files Browse the repository at this point in the history
Adjust husky task runner and reformat unit tests

This commit updates the husky task-runner.json file by commenting out the 'dotnet-format' task. It also includes reformatting of the Issue99Tests.cs unit test file to correct some inconsistencies in indentation and code organization.
  • Loading branch information
alirezanet committed Dec 17, 2023
1 parent b94296e commit ffc9926
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 47 deletions.
14 changes: 7 additions & 7 deletions .husky/task-runner.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
"command": "dotnet",
"args": ["husky", "exec", ".husky/csx/commit-lint.csx", "--args", "${args}"]
},
{
"name": "dotnet-format",
"command": "dotnet",
"group": "pre-commit",
"args": ["dotnet-format", "--include" , "${staged}"],
"include": ["**/*.cs"]
},
// {
// "name": "dotnet-format",
// "command": "dotnet",
// "group": "pre-commit",
// "args": ["dotnet-format", "--include" , "${staged}"],
// "include": ["**/*.cs"]
// },
{
"name": "update-version",
"command": "dotnet",
Expand Down
78 changes: 38 additions & 40 deletions tests/HuskyIntegrationTests/Issue99Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,63 +8,61 @@ namespace HuskyIntegrationTests;
public class Issue99Tests(DockerFixture docker, ITestOutputHelper output) : IClassFixture<DockerFixture>
{
[Fact]
public async Task StagedFiles_ShouldPassToJbCleanup_WithASemicolonSeparator()
{
// arrange
var c = await ArrangeContainer();

// add 4 c# files
for (var i = 2; i <= 4; i++)
public async Task StagedFiles_ShouldPassToJbCleanup_WithASemicolonSeparator()
{
var csharpFile =
// arrange
var c = await ArrangeContainer();

// add 4 c# files
for (var i = 2; i <= 4; i++)
{
var csharpFile =
$$"""
namespace TestProjectBase;
public class Class {{i }
}
{public static void TestMethod() { }
}
""";
public class Class{{i}} {
public static void TestMethod() { }
}
""";

await c.AddCsharpClass(csharpFile, $"Class{i}.cs");
}

await c.BashAsync("git add .");

// act
var result = await c.BashAsync(output, "git commit -m 'add 4 new csharp classes'");
var result = await c.BashAsync(output, "git commit -m 'add 4 new csharp classes'");

// assert
result.ExitCode.Should().Be(0);
result.Stderr.Should().Contain(Extensions.SuccessfullyExecuted);
result.ExitCode.Should().Be(0);
result.Stderr.Should().Contain(Extensions.SuccessfullyExecuted);
}

[Fact]
public async Task StagedFiles_ShouldSkip_WhenNoMatchFilesFound()
{
// arrange
var c = await ArrangeContainer();
await c.BashAsync("git add .");
public async Task StagedFiles_ShouldSkip_WhenNoMatchFilesFound()
{
// arrange
var c = await ArrangeContainer();
await c.BashAsync("git add .");

// act
var result = await c.BashAsync(output, "git commit -m 'add task-runner.json'");
// act
var result = await c.BashAsync(output, "git commit -m 'add task-runner.json'");

// assert
result.ExitCode.Should().Be(0);
result.Stderr.Should().Contain(Extensions.Skipped);
}
// assert
result.ExitCode.Should().Be(0);
result.Stderr.Should().Contain(Extensions.Skipped);
}

private async Task<IContainer> ArrangeContainer([CallerMemberName] string name = null!)
{
var c = await docker.StartWithInstalledHusky(name);
await c.BashAsync("dotnet tool install JetBrains.ReSharper.GlobalTools");
await c.BashAsync("dotnet tool restore");
await c.BashAsync("git add .");
await c.BashAsync("git commit -m 'add jb tool'");
private async Task<IContainer> ArrangeContainer([CallerMemberName] string name = null!)
{
var c = await docker.StartWithInstalledHusky(name);
await c.BashAsync("dotnet tool install JetBrains.ReSharper.GlobalTools");
await c.BashAsync("dotnet tool restore");
await c.BashAsync("git add .");
await c.BashAsync("git commit -m 'add jb tool'");

const string tasks =
"""
const string tasks =
"""
{
"tasks": [
"tasks": [
{
"name": "jb cleanup",
"group": "pre-commit",
Expand All @@ -82,7 +80,7 @@ private async Task<IContainer> ArrangeContainer([CallerMemberName] string name =
}
""";
await c.UpdateTaskRunner(tasks);
await c.BashAsync("dotnet husky add pre-commit -c 'dotnet husky run -g pre-commit'");
return c;
await c.BashAsync("dotnet husky add pre-commit -c 'dotnet husky run -g pre-commit'");
return c;
}
}

0 comments on commit ffc9926

Please sign in to comment.