-
Notifications
You must be signed in to change notification settings - Fork 4k
Clu test project and updates to clu-getstart.md #1680
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
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
85b048a
Initial test projects
BurtBiel 707df41
Merge pull request #6 from Azure/clu
BurtBiel 4d3bfb8
Refactoring for help unit tests, test content in progress
BurtBiel 439f54f
merge in latest clu
BurtBiel e609c74
incremental help test changes, merge with latest
BurtBiel 12ec017
Help tests final touches
BurtBiel ba5d969
Tidy up
BurtBiel 46d5061
Add assembly info, update getting started
BurtBiel 50ca6d3
Merge pull request #8 from Azure/clu
BurtBiel 1a8b229
merge changes to clu-getstart
BurtBiel f2be3e3
Added line breaks and one minor clu-getstart.md change
BurtBiel 422167f
Merge remote-tracking branch 'upstream/clu' into clu
BurtBiel de32aab
Merge branch 'clu'
BurtBiel 077f8d2
Fixing up missing Nuget.Commands dependency
BurtBiel 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Work on CLU cmdlets | ||
# Work on CLU cmdlets | ||
|
||
## Prerequsites | ||
|
||
|
@@ -25,7 +25,7 @@ CLUPackages require some additional files to direct generation of indexing, and | |
| ------------- |:-------------:| | ||
| CommandAssemblies | File name of cmdlets assembly(ies) | | ||
| NounPrefix | ‘AzureRm’ The part of the cmdlet noun to remove in clu commands| | ||
| NounFirst | if true, the verb comes at the end of the command (e.g. az resource get)| | ||
| NounFirst | if true, the verb comes at the end of the command (e.g. az resource ls)| | ||
|
||
* \<modulename\>.nuspec.template, which contains nuspec format metadata about the package – the base temaplate is in tools\clu\Microsoft.Azure.Commands.nuspec.template. Here are the special fields defined in this template: | ||
* %PackageId% - replace with the module name (Microsoft.Azure.Commands.\<rp-name\>) | ||
|
@@ -63,16 +63,16 @@ To test on osx/linux boxes, do #1, open `<repo-root>\drop\clurun`, copy the flav | |
(All of those are subject to change, contact yugangw or adxsdkdev for any questions) | ||
|
||
## Quick introductions on cmdlets | ||
* Run commands using the ‘az’ prefix, cmdlet nouns, and cmdlet verbs, for example, `az env get` maps to the cmdlet `Get-AzureRmEnvironment` | ||
* Cmdlet parameters use the double dash (--) so for example, getting a subscription with a particular name would be: `az subscription get –-SubscriptionName “name of subscription"` | ||
* Run commands using the ‘az’ prefix, cmdlet nouns, and cmdlet verbs, for example, `az env ls` maps to the cmdlet `Get-AzureRmEnvironment` | ||
* Cmdlet parameters use the double dash (--) so for example, getting a subscription with a particular name would be: `az subscription ls –-SubscriptionName “name of subscription"` | ||
* To log in, 3 options | ||
* login interactively using device flow, this is the only option for msa account or any org-id with 2fa enforced, example: `az account add` | ||
* login with user and password, this works on org-id w/o 2fa enforced, example: `az account add --Username [email protected] --Password password1` | ||
* login as service principal. Example: `az account add --ServicePrincipal --TenantId <tenant> --ApplicationId <id> --Secret <secret>` | ||
* login interactively using device flow, this is the only option for msa account or any org-id with 2fa enforced, example: `az login` | ||
* login with user and password, this works on org-id w/o 2fa enforced, example: `az login --Username [email protected] --Password password1` | ||
* login as service principal. Example: `az login --ServicePrincipal --TenantId <tenant> --ApplicationId <id> --Secret <secret>` | ||
* Piping between cmdlets should work the same way that Powerhell piping works | ||
```az subscription get --SubscriptionName | az context set``` | ||
```az subscription ls --SubscriptionName | az context set``` | ||
* You can capture piped output using redirection to a file - the result will be the json serialization of the output object. | ||
```az subscription get > subscriptions.json``` | ||
```az subscription ls > subscriptions.json``` | ||
* You can use file input to a parameter using '@' notation: | ||
```az command --param1 @file1.json``` | ||
Reads input from file1.json and attempts to deserialize the .net object that is the Parameter type for ```param1``` | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using Microsoft.Azure.Commands.ScenarioTest; | ||
using Microsoft.CLU.Help; | ||
using Moq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Microsoft.CLU.Test | ||
{ | ||
public class HelpTests | ||
{ | ||
private readonly Mock<IHelpPackageFinder> helpPackageFinderMock = new Mock<IHelpPackageFinder>(); | ||
|
||
public HelpTests() | ||
{ | ||
this.helpPackageFinderMock | ||
.Setup(m => m.FindPackages()) | ||
.Returns(() => | ||
{ | ||
return new List<CommandDispatchHelper.PkgInfo>() | ||
{ | ||
new MockPkgInfo("abc", "1.0.0", "abc.ext"), | ||
new MockPkgInfo("abc def", "1.0.0", "abc.def.ext"), | ||
new MockPkgInfo("abc def ghi", "1.0.0", "abc.def.ghi.ext"), | ||
new MockPkgInfo("ddd eee aaa", "1.0.0", "ddd.eee.aaa.ext"), | ||
}; | ||
}); | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestHelpStartsWith() | ||
{ | ||
var commandInfos = CommandDispatchHelper.CompleteCommands(this.helpPackageFinderMock.Object, new string[] { "a" }); | ||
Assert.Equal(3, commandInfos.Count()); | ||
Assert.Equal(commandInfos.Count(), commandInfos.Where(c => c.Discriminators.StartsWith("a")).Count()); | ||
|
||
commandInfos = CommandDispatchHelper.CompleteCommands(this.helpPackageFinderMock.Object, new string[] { "abc" }); | ||
Assert.Equal(3, commandInfos.Count()); | ||
Assert.Equal(commandInfos.ElementAt(0).Discriminators, "abc"); | ||
Assert.Equal(commandInfos.ElementAt(1).Discriminators, "abc def"); | ||
Assert.Equal(commandInfos.ElementAt(2).Discriminators, "abc def ghi"); | ||
|
||
commandInfos = CommandDispatchHelper.CompleteCommands(this.helpPackageFinderMock.Object, new string[] { "dd" }); | ||
Assert.Equal(1, commandInfos.Count()); | ||
Assert.Equal(commandInfos.Count(), commandInfos.Where(c => c.Discriminators.StartsWith("dd")).Count()); | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestHelpFileSearch() | ||
{ | ||
var helpInfo = CommandDispatchHelper.FindBestHelp(this.helpPackageFinderMock.Object, new string[] { "abc" }); | ||
Assert.NotNull(helpInfo); | ||
Assert.Equal(helpInfo.Discriminators, "abc"); | ||
|
||
helpInfo = CommandDispatchHelper.FindBestHelp(this.helpPackageFinderMock.Object, new string[] { "abc", "def" }); | ||
Assert.NotNull(helpInfo); | ||
Assert.Equal(helpInfo.Discriminators, "abc;def"); | ||
|
||
helpInfo = CommandDispatchHelper.FindBestHelp(this.helpPackageFinderMock.Object, new string[] { "abc", "def", "ghi" }); | ||
Assert.NotNull(helpInfo); | ||
Assert.Equal(helpInfo.Discriminators, "abc;def;ghi"); | ||
} | ||
} | ||
} |
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,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0.24711" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.24711</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" /> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>13c34370-51a4-4726-81b8-be0996fc9cf0</ProjectGuid> | ||
<RootNamespace>Microsoft.CLU.Test</RootNamespace> | ||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath> | ||
<OutputPath Condition="'$(OutputPath)'=='' ">..\artifacts\bin\$(MSBuildProjectName)\</OutputPath> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> | ||
</ItemGroup> | ||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.CLU.Help; | ||
|
||
namespace Microsoft.CLU.Test | ||
{ | ||
internal class MockPkgInfo : Help.CommandDispatchHelper.PkgInfo | ||
{ | ||
public MockPkgInfo(string name, string version, string fullPath) : base(name, version, fullPath) | ||
{ | ||
|
||
} | ||
|
||
public override IEnumerable<CommandDispatchHelper.CommandInfo> GetCommands() | ||
{ | ||
yield return new CommandDispatchHelper.CommandInfo() | ||
{ | ||
Discriminators = Name, | ||
Package = this | ||
}; | ||
} | ||
|
||
public override IEnumerable<CommandDispatchHelper.HelpInfo> GetHelp() | ||
{ | ||
yield return new CommandDispatchHelper.HelpInfo(Path); | ||
} | ||
} | ||
} |
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,35 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// Copyright Microsoft Corporation | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Microsoft.CLU.Test")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Microsoft.CLU.Test")] | ||
[assembly: AssemblyCopyright("Copyright © Microsoft")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
[assembly: ComVisible(false)] | ||
|
||
[assembly: Guid("28fe3fc0-6fdf-4f01-8a82-d7b4a834ddd3")] | ||
|
||
[assembly: AssemblyVersion("1.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0")] |
This file was deleted.
Oops, something went wrong.
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,69 @@ | ||
{ | ||
"version": "1.0.0-*", | ||
"description": "Tests for CLU", | ||
"authors": [ "burtbiel" ], | ||
"tags": [ "" ], | ||
"projectUrl": "", | ||
"licenseUrl": "", | ||
"frameworks": { | ||
"dnxcore50": { | ||
"dependencies": { | ||
"Microsoft.NETCore": "5.0.1-beta-23516", | ||
"Microsoft.NETCore.Platforms": "1.0.1-beta-23516", | ||
"Microsoft.CSharp": "4.0.1-beta-23516" | ||
} | ||
} | ||
}, | ||
"dependencies": { | ||
"Commands.Common": "", | ||
"Commands.Common.Authentication": "", | ||
"Commands.ResourceManager.Common": "", | ||
"Commands.ResourceManager.Cmdlets": "", | ||
"Commands.ScenarioTests.ResourceManager.Common": "", | ||
"Microsoft.Azure.Commands.Profile": "", | ||
"Microsoft.Azure.Commands.Resources": "", | ||
"Microsoft.Azure.Graph.RBAC": "2.1.1-preview", | ||
"Microsoft.Azure.Management.Authorization": "2.3.0-preview", | ||
"Microsoft.Azure.Management.Resources": "3.3.1-preview", | ||
"Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.212041202-alpha", | ||
"Microsoft.Rest.ClientRuntime": "1.8.2", | ||
"Microsoft.Rest.ClientRuntime.Azure": "2.5.4", | ||
"Microsoft.Rest.ClientRuntime.Azure.Authentication": "1.2.1-preview", | ||
"Newtonsoft.Json": "7.0.1", | ||
"System.Collections": "4.0.11-beta-23516", | ||
"System.Collections.Concurrent": "4.0.11-beta-23516", | ||
"System.Diagnostics.Tools": "4.0.1-beta-23516", | ||
"System.Diagnostics.TraceSource": "4.0.0-beta-23516", | ||
"System.Diagnostics.Tracing": "4.0.21-beta-23516", | ||
"System.IO": "4.0.11-beta-23516", | ||
"System.IO.FileSystem": "4.0.1-beta-23516", | ||
"System.Net.Http": "4.0.1-beta-23516", | ||
"System.Net.WebHeaderCollection": "4.0.1-beta-23516", | ||
"System.Reflection": "4.1.0-beta-23516", | ||
"System.Reflection.Extensions": "4.0.1-beta-23516", | ||
"System.Reflection.Primitives": "4.0.1-beta-23516", | ||
"System.Reflection.TypeExtensions": "4.1.0-beta-23516", | ||
"System.Runtime": "4.0.21-beta-23516", | ||
"System.Runtime.Extensions": "4.0.11-beta-23516", | ||
"System.Runtime.Serialization.Json": "4.0.1-beta-23516", | ||
"System.Runtime.Serialization.Primitives": "4.1.0-beta-23516", | ||
"System.Runtime.Serialization.Xml": "4.1.0-beta-23516", | ||
"System.Security.Cryptography.Algorithms": "4.0.0-beta-23516", | ||
"System.Security.Cryptography.X509Certificates": "4.0.0-beta-23516", | ||
"System.Text.Encoding": "4.0.11-beta-23516", | ||
"System.Text.Encoding.Extensions": "4.0.11-beta-23516", | ||
"System.Threading": "4.0.11-beta-23516", | ||
"System.Threading.Tasks": "4.0.11-beta-23516", | ||
"System.Threading.Thread": "4.0.0-beta-23516", | ||
"System.Xml.ReaderWriter": "4.0.11-beta-23516", | ||
"xunit": "2.1.0", | ||
"xunit.assert": "2.1.0", | ||
"xunit.runner.dnx": "2.1.0-rc1-build204", | ||
"moq.netcore": "4.4.0-beta8", | ||
"Microsoft.CLU": "1.0.0", | ||
"System.Linq": "4.0.1-beta-23409" | ||
}, | ||
"commands": { | ||
"test": "xunit.runner.dnx" | ||
} | ||
} |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Factored out the package path into HelpPackageFinder so we can create our own packages in the unit tests