-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add IntegrationTest project (#100)
* test: add husky integration test project * chore: Remove unused "Issue99" folder from HuskyIntegrationTests The "Issue99" folder is not being used anymore in the HuskyIntegrationTests project. This commit removes the redundant folder reference from the project file to keep the project structure clean and accurate. * fix: add integration Test base project template * test: Add new method in DockerFixture and modify tests A new method `StartWithInstalledHusky` has been added to `DockerFixture`, this method provides an easier way to get a container with Husky installed. Some code rearrangement and wording modifications were made in the `Extensions` and `Tests` classes to make test cases clearer and more understandable. The newly created TestProjectBase solution was also added. * test: Update BashAsync method and enhance Docker setup The BashAsync method in Extensions.cs now handles exceptions for non-zero exit codes, enhancing error handling. A new method, AddCsharpClass, has also been added to help create C# classes. In DockerFixture.cs, global user details are now set up to aid Git operations.
- Loading branch information
1 parent
9c334c8
commit ca61a32
Showing
16 changed files
with
854 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Exclude everything | ||
* | ||
|
||
# Include the src folder | ||
!src | ||
!README.md | ||
|
||
# Exclude build-related folders within src/Husky | ||
src/Husky/bin/ | ||
src/Husky/obj/ | ||
src/Husky/nupkg/ |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# This dockerfile is used in the integration tests | ||
|
||
# Use the official .NET SDK image as a base | ||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env | ||
ARG RESOURCE_REAPER_SESSION_ID="00000000-0000-0000-0000-000000000000" | ||
LABEL "org.testcontainers.resource-reaper-session"=$RESOURCE_REAPER_SESSION_ID | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy the .csproj file to the container | ||
COPY src/Husky/Husky.csproj ./ | ||
|
||
ENV HUSKY=0 | ||
|
||
# Copy the remaining files to the container | ||
COPY . ./ | ||
|
||
# Restore dependencies | ||
RUN dotnet restore /app/src/Husky | ||
|
||
# Build the application | ||
RUN dotnet build --no-restore -c Release -f net8.0 /app/src/Husky | ||
|
||
# Create a NuGet package | ||
RUN dotnet pack --no-build --no-restore -c Release -o out /app/src/Husky/Husky.csproj -p:TargetFrameworks=net8.0 | ||
|
||
# Use the same .NET SDK image for the final stage | ||
FROM mcr.microsoft.com/dotnet/sdk:8.0 | ||
ARG RESOURCE_REAPER_SESSION_ID="00000000-0000-0000-0000-000000000000" | ||
LABEL "org.testcontainers.resource-reaper-session"=$RESOURCE_REAPER_SESSION_ID | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Install Git | ||
RUN apt-get update && \ | ||
apt-get install -y git | ||
|
||
# Copy the NuGet package from the build-env to the runtime image | ||
COPY --from=build-env /app/out/*.nupkg /app/nupkg/ | ||
|
||
# Install Husky tool and add the global tools path to the PATH | ||
RUN dotnet tool install -g --no-cache --add-source /app/nupkg/ husky \ | ||
&& echo "export PATH=\$PATH:/root/.dotnet/tools" >> ~/.bashrc | ||
|
||
# Set the entry point to a simple shell | ||
ENTRYPOINT ["/bin/bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="6.12.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/> | ||
<PackageReference Include="Testcontainers" Version="3.6.0" /> | ||
<PackageReference Include="xunit" Version="2.4.2"/> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="TestProjectBase\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
12 changes: 12 additions & 0 deletions
12
tests/HuskyIntegrationTests/TestProjectBase/.config/dotnet-tools.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": 1, | ||
"isRoot": true, | ||
"tools": { | ||
"husky": { | ||
"version": "0.6.3", | ||
"commands": [ | ||
"husky" | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.