-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
116 additions
and
0 deletions.
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
68 changes: 68 additions & 0 deletions
68
src/tests/OpenApiGenerator.IntegrationTests.Cli/CliTests.cs
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,68 @@ | ||
using CliWrap.Buffered; | ||
|
||
namespace OpenApiGenerator.IntegrationTests; | ||
|
||
[TestClass] | ||
public class CliTests | ||
{ | ||
[DataTestMethod] | ||
//[DataRow("github.yaml")] | ||
[DataRow("ipinfo.yaml")] | ||
[DataRow("langsmith.yaml")] | ||
//[DataRow("langsmith.json")] | ||
[DataRow("ollama.yaml")] | ||
[DataRow("openai.yaml")] | ||
[DataRow("petstore.yaml")] | ||
[DataRow("replicate.json")] | ||
//[DataRow("special-cases.yaml")] | ||
[DataRow("twitch.json")] | ||
public async Task Run(string spec) | ||
{ | ||
var tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); | ||
try | ||
{ | ||
Directory.CreateDirectory(tempDirectory); | ||
|
||
var currentDirectory = Directory.GetCurrentDirectory(); | ||
var repositoryDirectory = Path.GetFullPath(Path.Combine(currentDirectory, "../../../../../..")); | ||
_ = await CliWrap.Cli.Wrap("dotnet") | ||
.WithArguments([ | ||
"run", | ||
"--project", "src/libs/OpenApiGenerator.Cli", | ||
"generate", $"specs/{spec}", | ||
"--output", tempDirectory, | ||
"--namespace", "Oag", | ||
// --json-serializer-type SystemTextJson --target-framework netstandard2.0 --generate-sdk | ||
]) | ||
.WithWorkingDirectory(repositoryDirectory) | ||
.ExecuteBufferedAsync(); | ||
|
||
Directory.EnumerateFiles(tempDirectory, "*", SearchOption.AllDirectories) | ||
.Should() | ||
.NotBeEmpty(); | ||
|
||
await File.WriteAllTextAsync(Path.Combine(tempDirectory, "Oag.csproj"), @"<Project Sdk=""Microsoft.NET.Sdk""> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
</PropertyGroup> | ||
<PropertyGroup Label=""Analyzers""> | ||
<EnableNETAnalyzers>true</EnableNETAnalyzers> | ||
<AnalysisLevel>latest</AnalysisLevel> | ||
<AnalysisMode>All</AnalysisMode> | ||
</PropertyGroup> | ||
</Project>"); | ||
|
||
var response = await DotnetCliWrapper.Dotnet.BuildAsync(tempDirectory + "/"); | ||
Console.WriteLine(response.StandardOutput); | ||
Console.WriteLine(response.StandardError); | ||
response.Diagnostics.Should().BeEmpty(); | ||
} | ||
finally | ||
{ | ||
Directory.Delete(tempDirectory, recursive: true); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/tests/OpenApiGenerator.IntegrationTests.Cli/OpenApiGenerator.IntegrationTests.Cli.csproj
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,41 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Label="Base packages"> | ||
<PackageReference Include="CliWrap" Version="3.6.6" /> | ||
<PackageReference Include="DotnetCliWrapper" Version="0.1.0" /> | ||
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="3.4.3" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="3.4.3" /> | ||
<PackageReference Include="FluentAssertions" Version="6.12.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Label="GlobalUsings"> | ||
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" /> | ||
<Using Include="FluentAssertions" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="H.Resources.Generator" Version="1.6.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" /> | ||
<PackageReference Include="Microsoft.OpenApi" Version="1.6.14" /> | ||
<PackageReference Include="Microsoft.OpenApi.Readers" Version="1.6.14" /> | ||
<PackageReference Include="SharpYaml" Version="2.1.1" /> | ||
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\libs\OpenApiGenerator.Cli\OpenApiGenerator.Cli.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |