-
Notifications
You must be signed in to change notification settings - Fork 369
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
1 parent
348b46c
commit ec25b81
Showing
13 changed files
with
372 additions
and
6 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
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
21 changes: 21 additions & 0 deletions
21
...asks.IntegrationTests/Resources/InvalidTemplatePackage_MissingName/TemplatePackage.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,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<PackageType>Template</PackageType> | ||
<PackageId>TemplatePackage</PackageId> | ||
<Authors>Microsoft</Authors> | ||
<Description>TemplatePackage</Description> | ||
<IncludeContentInPack>true</IncludeContentInPack> | ||
<IncludeBuildOutput>false</IncludeBuildOutput> | ||
<ContentTargetFolders>content</ContentTargetFolders> | ||
<NoWarn>$(NoWarn);NU5128</NoWarn> | ||
<IsPackable>true</IsPackable> | ||
<IsShipping>false</IsShipping> | ||
<NoDefaultExcludes>true</NoDefaultExcludes> | ||
<LocalizeTemplates>true</LocalizeTemplates> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Remove="**\*" /> | ||
<Content Include="content\**\*" Exclude="content\**\bin\**;content\**\obj\**" /> | ||
</ItemGroup> | ||
</Project> |
10 changes: 10 additions & 0 deletions
10
...TemplatePackage_MissingName/content/TemplateWithSourceName/.template.config/template.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,10 @@ | ||
{ | ||
"author": "Test Asset", | ||
"classifications": [ "Test Asset" ], | ||
"description": "Test description", | ||
"generatorVersions": "[1.0.0.0-*)", | ||
"groupIdentity": "TestAssets.TemplateWithSourceName", | ||
"precedence": "100", | ||
"identity": "TestAssets.TemplateWithSourceName", | ||
"sourceName": "bar" | ||
} |
6 changes: 6 additions & 0 deletions
6
...nTests/Resources/InvalidTemplatePackage_MissingName/content/TemplateWithSourceName/foo.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,6 @@ | ||
namespace TemplateWithSourceName | ||
{ | ||
internal class Foo | ||
{ | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...egrationTests/Resources/InvalidTemplatePackage_MissingOptionalData/TemplatePackage.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,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<PackageType>Template</PackageType> | ||
<PackageId>TemplatePackage</PackageId> | ||
<Authors>Microsoft</Authors> | ||
<Description>TemplatePackage</Description> | ||
<IncludeContentInPack>true</IncludeContentInPack> | ||
<IncludeBuildOutput>false</IncludeBuildOutput> | ||
<ContentTargetFolders>content</ContentTargetFolders> | ||
<NoWarn>$(NoWarn);NU5128</NoWarn> | ||
<IsPackable>true</IsPackable> | ||
<IsShipping>false</IsShipping> | ||
<NoDefaultExcludes>true</NoDefaultExcludes> | ||
<LocalizeTemplates>true</LocalizeTemplates> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Remove="**\*" /> | ||
<Content Include="content\**\*" Exclude="content\**\bin\**;content\**\obj\**" /> | ||
</ItemGroup> | ||
</Project> |
10 changes: 10 additions & 0 deletions
10
...Package_MissingOptionalData/content/TemplateWithSourceName/.template.config/template.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,10 @@ | ||
{ | ||
"name": "TemplateWithSourceName", | ||
"description": "Test description", | ||
"generatorVersions": "[1.0.0.0-*)", | ||
"groupIdentity": "TestAssets.TemplateWithSourceName", | ||
"precedence": "100", | ||
"identity": "TestAssets.TemplateWithSourceName", | ||
"shortName": "TestAssets.TemplateWithSourceName", | ||
"sourceName": "bar" | ||
} |
6 changes: 6 additions & 0 deletions
6
...esources/InvalidTemplatePackage_MissingOptionalData/content/TemplateWithSourceName/foo.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,6 @@ | ||
namespace TemplateWithSourceName | ||
{ | ||
internal class Foo | ||
{ | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
test/Microsoft.TemplateEngine.Authoring.Tasks.IntegrationTests/ValidateTemplatesTests.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,70 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using FluentAssertions; | ||
using Microsoft.TemplateEngine.CommandUtils; | ||
using Microsoft.TemplateEngine.TestHelper; | ||
using Microsoft.TemplateEngine.Tests; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Microsoft.TemplateEngine.Authoring.Tasks.IntegrationTests | ||
{ | ||
public class ValidateTemplatesTests : TestBase | ||
{ | ||
private readonly ITestOutputHelper _log; | ||
|
||
public ValidateTemplatesTests(ITestOutputHelper log) | ||
{ | ||
_log = log; | ||
} | ||
|
||
[Fact] | ||
public void CanRunValidateTask_OnError() | ||
{ | ||
string tmpDir = TestUtils.CreateTemporaryFolder(); | ||
TestUtils.DirectoryCopy("Resources/InvalidTemplatePackage_MissingName", tmpDir, true); | ||
TestUtils.SetupNuGetConfigForPackagesLocation(tmpDir, ShippingPackagesLocation); | ||
|
||
new DotnetCommand(_log, "add", "TemplatePackage.csproj", "package", "Microsoft.TemplateEngine.Authoring.Tasks", "--prerelease") | ||
.WithoutTelemetry() | ||
.WithWorkingDirectory(tmpDir) | ||
.Execute() | ||
.Should() | ||
.Pass(); | ||
|
||
new DotnetCommand(_log, "build") | ||
.WithoutTelemetry() | ||
.WithWorkingDirectory(tmpDir) | ||
.Execute() | ||
.Should() | ||
.Fail() | ||
.And.HaveStdOutContaining("Template configuration error MV002: Missing 'name'.") | ||
.And.HaveStdOutContaining("Template configuration error MV003: Missing 'shortName'."); | ||
} | ||
|
||
[Fact] | ||
public void CanRunValidateTask_OnInfo() | ||
{ | ||
string tmpDir = TestUtils.CreateTemporaryFolder(); | ||
TestUtils.DirectoryCopy("Resources/InvalidTemplatePackage_MissingOptionalData", tmpDir, true); | ||
TestUtils.SetupNuGetConfigForPackagesLocation(tmpDir, ShippingPackagesLocation); | ||
|
||
new DotnetCommand(_log, "add", "TemplatePackage.csproj", "package", "Microsoft.TemplateEngine.Authoring.Tasks", "--prerelease") | ||
.WithoutTelemetry() | ||
.WithWorkingDirectory(tmpDir) | ||
.Execute() | ||
.Should() | ||
.Pass(); | ||
|
||
new DotnetCommand(_log, "build") | ||
.WithoutTelemetry() | ||
.WithWorkingDirectory(tmpDir) | ||
.Execute() | ||
.Should() | ||
.Pass() | ||
.And.HaveStdOutContaining("Template configuration message MV006: Missing 'author'.") | ||
.And.HaveStdOutContaining("Template configuration message MV010: Missing 'classifications'."); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.