-
Notifications
You must be signed in to change notification settings - Fork 829
Test templates #6086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Test templates #6086
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -50,6 +50,7 @@ TestResult.xml | |
|
||
# VERIFY | ||
*.received.* | ||
**/*.received/ | ||
|
||
# Build Results of an ATL Project | ||
[Dd]ebugPS/ | ||
|
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -1,13 +1,16 @@ | ||
<Project Sdk="Microsoft.Build.Traversal"> | ||
<ItemGroup> | ||
<_SnapshotsToExclude Include="$(MSBuildThisFileDirectory)..\test\**\Snapshots\**\*.*proj" /> | ||
|
||
<!-- We recursively add all of the projects inside the src directory, except for the exclusions above --> | ||
<_ProjectsToBuild Include="$(MSBuildThisFileDirectory)..\src\**\*.csproj" Exclude="@(_ProjectsToExclude)" /> | ||
<_ProjectsToBuild Include="$(MSBuildThisFileDirectory)..\src\**\*.csproj" /> | ||
<!-- We recursively add all of the test projects --> | ||
<_ProjectsToBuild Include="$(MSBuildThisFileDirectory)..\test\**\*.csproj" /> | ||
<_ProjectsToBuild Include="$(MSBuildThisFileDirectory)..\bench\**\*.csproj" /> | ||
<!-- Additionally, include the transport project that is not defined as a csproj --> | ||
<_ProjectsToBuild Include="$(MSBuildThisFileDirectory)..\src\Packages\Microsoft.Internal.Extensions.DotNetApiDocs.Transport\Microsoft.Internal.Extensions.DotNetApiDocs.Transport.proj" /> | ||
|
||
<!-- Add all the projects we want to build as project references, so the traversal SDK can build them --> | ||
<ProjectReference Include="@(_ProjectsToBuild)" /> | ||
<ProjectReference Include="@(_ProjectsToBuild)" Exclude="@(_ProjectsToExclude);@(_SnapshotsToExclude)" /> | ||
</ItemGroup> | ||
</Project> |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
10 changes: 10 additions & 0 deletions
10
...nitoring.Tests/Linux/Verified/LinuxNetworkUtilizationParserTests.1.DotNet9_0.verified.txt
This file contains hidden or 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,10 @@ | ||
{ | ||
Type: InvalidOperationException, | ||
Message: Could not split contents. We expected every line to contain more than 4 elements, but it has only 2 elements., | ||
StackTrace: | ||
at Microsoft.Shared.Diagnostics.Throw.InvalidOperationException(String message) | ||
at Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux.Network.LinuxNetworkUtilizationParser.UpdateTcpStateInfo(ReadOnlySpan`1 buffer, TcpStateInfo tcpStateInfo) | ||
at Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux.Network.LinuxNetworkUtilizationParser.GetTcpStateInfo(FileInfo file) | ||
at Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux.Network.LinuxNetworkUtilizationParser.GetTcpIPv4StateInfo() | ||
at Xunit.Record.Exception(Func`1 testCode) | ||
} |
10 changes: 10 additions & 0 deletions
10
...nitoring.Tests/Linux/Verified/LinuxNetworkUtilizationParserTests.2.DotNet9_0.verified.txt
This file contains hidden or 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,10 @@ | ||
{ | ||
Type: InvalidOperationException, | ||
Message: Could not split contents. We expected every line to contain more than 4 elements, but it has only 2 elements., | ||
StackTrace: | ||
at Microsoft.Shared.Diagnostics.Throw.InvalidOperationException(String message) | ||
at Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux.Network.LinuxNetworkUtilizationParser.UpdateTcpStateInfo(ReadOnlySpan`1 buffer, TcpStateInfo tcpStateInfo) | ||
at Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux.Network.LinuxNetworkUtilizationParser.GetTcpStateInfo(FileInfo file) | ||
at Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux.Network.LinuxNetworkUtilizationParser.GetTcpIPv4StateInfo() | ||
at Xunit.Record.Exception(Func`1 testCode) | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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
79 changes: 79 additions & 0 deletions
79
...ctTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/AichatwebTemplatesTests.cs
This file contains hidden or 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,79 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.IO; | ||
using System.Threading.Tasks; | ||
using EmptyFiles; | ||
using Microsoft.Extensions.AI.Templates.IntegrationTests; | ||
using Microsoft.Extensions.AI.Templates.Tests; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.TemplateEngine.Authoring.TemplateVerifier; | ||
using Microsoft.TemplateEngine.TestHelper; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Microsoft.Extensions.AI.Templates.InegrationTests; | ||
|
||
public class AichatwebTemplatesTests : TestBase | ||
{ | ||
private readonly ILogger _log; | ||
|
||
public AichatwebTemplatesTests(ITestOutputHelper log) | ||
{ | ||
#pragma warning disable CA2000 // Dispose objects before losing scope | ||
_log = new XunitLoggerProvider(log).CreateLogger("TestRun"); | ||
#pragma warning restore CA2000 // Dispose objects before losing scope | ||
} | ||
|
||
[Fact] | ||
public async Task BasicTest() | ||
{ | ||
string workingDir = TestUtils.CreateTemporaryFolder(); | ||
string templateShortName = "aichatweb"; | ||
|
||
// Get the template location | ||
string templateLocation = Path.Combine(TemplateFeedLocation, "Microsoft.Extensions.AI.Templates", "src", "ChatWithCustomData"); | ||
|
||
// Treat *.in files as text, see https://github.com/VerifyTests/EmptyFiles#istext | ||
FileExtensions.AddTextExtension(".in"); | ||
|
||
TemplateVerifierOptions options = new TemplateVerifierOptions(templateName: templateShortName) | ||
{ | ||
TemplatePath = templateLocation, | ||
SnapshotsDirectory = "Snapshots", | ||
OutputDirectory = workingDir, | ||
DoNotPrependCallerMethodNameToScenarioName = true, | ||
ScenarioName = "Basic", | ||
} | ||
.WithCustomScrubbers( | ||
ScrubbersDefinition.Empty.AddScrubber((path, content) => | ||
{ | ||
string filePath = path.UnixifyDirSeparators(); | ||
if (filePath.EndsWith("aichatweb/ChatWithCustomData.Web/ChatWithCustomData.Web.csproj") || | ||
filePath.EndsWith("aichatweb/aichatweb.csproj") || | ||
filePath.EndsWith("aichatweb/aichatweb.csproj.in")) | ||
{ | ||
content.ScrubByRegex("<UserSecretsId>(.*)<\\/UserSecretsId>", "<UserSecretsId>secret</UserSecretsId>"); | ||
} | ||
|
||
if (filePath.EndsWith("aichatweb/Properties/launchSettings.json")) | ||
{ | ||
content.ScrubByRegex("(http(s?):\\/\\/localhost)\\:(\\d*)", "$1:9999"); | ||
} | ||
})); | ||
|
||
VerificationEngine engine = new VerificationEngine(_log); | ||
await engine.Execute(options); | ||
|
||
#pragma warning disable CA1031 // Do not catch general exception types | ||
try | ||
{ | ||
Directory.Delete(workingDir, recursive: true); | ||
} | ||
catch | ||
{ | ||
/* don't care */ | ||
} | ||
#pragma warning restore CA1031 // Do not catch general exception types | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...t.Extensions.AI.Templates.IntegrationTests/Microsoft.Extensions.AI.Templates.Tests.csproj
This file contains hidden or 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,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<Description>Unit tests for Microsoft.Extensions.AI.Templates.</Description> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<NoWarn>$(NoWarn);CA1063;CA1861;CA2201;VSTHRD003;S104;S125;S2699</NoWarn> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.TemplateEngine.Authoring.TemplateVerifier" /> | ||
<PackageReference Include="Microsoft.TemplateEngine.TestHelper" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Remove="Snapshots\**\*.*" /> | ||
<None Include="Snapshots\**\*.*" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
|
24 changes: 24 additions & 0 deletions
24
...plates.IntegrationTests/Snapshots/aichatweb.Basic.verified/aichatweb/Components/App.razor
This file contains hidden or 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,24 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<base href="/" /> | ||
<link rel="stylesheet" href="@Assets["app.css"]" /> | ||
<link rel="stylesheet" href="@Assets["aichatweb.styles.css"]" /> | ||
<ImportMap /> | ||
<HeadOutlet @rendermode="@renderMode" /> | ||
</head> | ||
|
||
<body> | ||
<Routes @rendermode="@renderMode" /> | ||
<script src="@Assets["app.js"]" type="module"></script> | ||
<script src="@Assets["_framework/blazor.web.js"]"></script> | ||
</body> | ||
|
||
</html> | ||
|
||
@code { | ||
private readonly IComponentRenderMode renderMode = new InteractiveServerRenderMode(prerender: false); | ||
} |
1 change: 1 addition & 0 deletions
1
...Tests/Snapshots/aichatweb.Basic.verified/aichatweb/Components/Layout/LoadingSpinner.razor
This file contains hidden or 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 @@ | ||
<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div> |
89 changes: 89 additions & 0 deletions
89
...s/Snapshots/aichatweb.Basic.verified/aichatweb/Components/Layout/LoadingSpinner.razor.css
This file contains hidden or 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,89 @@ | ||
/* Used under CC0 license */ | ||
|
||
.lds-ellipsis { | ||
color: #666; | ||
animation: fade-in 1s; | ||
} | ||
|
||
@keyframes fade-in { | ||
0% { | ||
opacity: 0; | ||
} | ||
|
||
100% { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
.lds-ellipsis, | ||
.lds-ellipsis div { | ||
box-sizing: border-box; | ||
} | ||
|
||
.lds-ellipsis { | ||
margin: auto; | ||
display: block; | ||
position: relative; | ||
width: 80px; | ||
height: 80px; | ||
} | ||
|
||
.lds-ellipsis div { | ||
position: absolute; | ||
top: 33.33333px; | ||
width: 10px; | ||
height: 10px; | ||
border-radius: 50%; | ||
background: currentColor; | ||
animation-timing-function: cubic-bezier(0, 1, 1, 0); | ||
} | ||
|
||
.lds-ellipsis div:nth-child(1) { | ||
left: 8px; | ||
animation: lds-ellipsis1 0.6s infinite; | ||
} | ||
|
||
.lds-ellipsis div:nth-child(2) { | ||
left: 8px; | ||
animation: lds-ellipsis2 0.6s infinite; | ||
} | ||
|
||
.lds-ellipsis div:nth-child(3) { | ||
left: 32px; | ||
animation: lds-ellipsis2 0.6s infinite; | ||
} | ||
|
||
.lds-ellipsis div:nth-child(4) { | ||
left: 56px; | ||
animation: lds-ellipsis3 0.6s infinite; | ||
} | ||
|
||
@keyframes lds-ellipsis1 { | ||
0% { | ||
transform: scale(0); | ||
} | ||
|
||
100% { | ||
transform: scale(1); | ||
} | ||
} | ||
|
||
@keyframes lds-ellipsis3 { | ||
0% { | ||
transform: scale(1); | ||
} | ||
|
||
100% { | ||
transform: scale(0); | ||
} | ||
} | ||
|
||
@keyframes lds-ellipsis2 { | ||
0% { | ||
transform: translate(0, 0); | ||
} | ||
|
||
100% { | ||
transform: translate(24px, 0); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...tionTests/Snapshots/aichatweb.Basic.verified/aichatweb/Components/Layout/MainLayout.razor
This file contains hidden or 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,9 @@ | ||
@inherits LayoutComponentBase | ||
|
||
@Body | ||
|
||
<div id="blazor-error-ui" data-nosnippet> | ||
An unhandled error has occurred. | ||
<a href="." class="reload">Reload</a> | ||
<span class="dismiss">🗙</span> | ||
</div> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.