Skip to content

Commit

Permalink
asyncapi#196 Pack_Install_Run_Uninstall fix casing in test, add meta …
Browse files Browse the repository at this point in the history
…data to package
  • Loading branch information
Senn Geerts authored and Senn Geerts committed Jul 6, 2024
1 parent 0419101 commit 12593dc
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>12</LangVersion>
<RootNamespace>AsyncAPI.Saunter.Generator.Cli</RootNamespace>

<Description>AsyncAPI Command Line Tools</Description>
<OutputType>Exe</OutputType>
<Authors>AsyncAPI Initiative</Authors>
<PackAsTool>true</PackAsTool>
<PackageId>AsyncAPI.Saunter.Generator.Cli</PackageId>
<ToolCommandName>AsyncAPI.NET</ToolCommandName>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<PackageTags>asyncapi;aspnetcore;openapi;documentation;amqp;generator;cli;tool</PackageTags>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<PackageIcon>logo.png</PackageIcon>
<RepositoryUrl>https://github.com/asyncapi/saunter</RepositoryUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<PackageProjectUrl>https://github.com/asyncapi/saunter</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard2.0' ">
Expand All @@ -25,5 +33,10 @@
<ItemGroup>
<ProjectReference Include="..\Saunter\Saunter.csproj" />
</ItemGroup>


<ItemGroup>
<None Include="readme.md" Pack="true" PackagePath="\"/>
<None Include="../../assets/logo.png" Pack="true" PackagePath="/" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@
<Using Include="Xunit" />
</ItemGroup>

<ItemGroup>
<None Update="asyncapi.cmd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Diagnostics;
using Shouldly;
using Xunit.Abstractions;

namespace AsyncAPI.Saunter.Generator.Cli.Tests;

public class PackAndInstallLocalTests(ITestOutputHelper output)
{
private string Run(string file, string args, string workingDirectory, int expectedExitCode = 0)
{
var process = Process.Start(new ProcessStartInfo(file)
{
Arguments = args,
WorkingDirectory = workingDirectory,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
});
process.WaitForExit(TimeSpan.FromSeconds(20));
var stdOut = process.StandardOutput.ReadToEnd().Trim();
var stdError = process.StandardError.ReadToEnd().Trim();
output.WriteLine($"### Output of \"{file} {args}\"");
output.WriteLine(stdOut);
output.WriteLine(stdError);

process.ExitCode.ShouldBe(expectedExitCode);
return stdOut;
}

[Fact]
public void Pack_Install_Run_Uninstall_Test()
{
var stdOut = this.Run("dotnet", "pack", "../../../../../src/AsyncAPI.Saunter.Generator.Cli");
stdOut.ShouldContain("Successfully created package");

stdOut = this.Run("dotnet", "tool install --global --add-source ./bin/Release AsyncAPI.Saunter.Generator.Cli", "../../../../../src/AsyncAPI.Saunter.Generator.Cli");
stdOut.ShouldBeOneOf("You can invoke the tool using the following command: AsyncAPI.NET\r\nTool 'asyncapi.saunter.generator.cli' (version '1.0.0') was successfully installed.",
"Tool 'asyncapi.saunter.generator.cli' was reinstalled with the stable version (version '1.0.0').");

stdOut = this.Run("dotnet", "tool list -g asyncapi.saunter.generator.cli", "");
stdOut.ShouldContain("AsyncAPI.NET");

stdOut = this.Run("asyncapi.cmd", "", "", 1);
stdOut.ShouldContain("tofile: retrieves AsyncAPI from a startup assembly, and writes to file");

stdOut = this.Run("dotnet", "tool uninstall -g asyncapi.saunter.generator.cli", "");
stdOut.ShouldContain(" was successfully uninstalled.");

stdOut = this.Run("dotnet", "tool list -g asyncapi.saunter.generator.cli", "", 1);
stdOut.ShouldNotContain("AsyncAPI.NET");
}
}
1 change: 1 addition & 0 deletions test/AsyncAPI.Saunter.Generator.Cli.Tests/asyncapi.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AsyncAPI.NET

0 comments on commit 12593dc

Please sign in to comment.