Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
thomhurst committed Dec 21, 2023
1 parent 7fee8ed commit 9aa3be9
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions test/ModularPipelines.UnitTests/CommandParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ public class AzureCommandModule : Module<CommandResult>
}, cancellationToken);
}
}

public class AzureCommandModule2 : Module<CommandResult>
{
protected override async Task<CommandResult?> ExecuteAsync(IPipelineContext context, CancellationToken cancellationToken)
{
return await context.Azure().Az.Account.ManagementGroup.Subscription.Add(new AzAccountManagementGroupSubscriptionAddOptions("MyName", "MySub")
{
InternalDryRun = true
}, cancellationToken);
}
}

[Test]
public async Task Empty_Options_Parse_As_Expected()
Expand Down Expand Up @@ -153,9 +164,19 @@ public async Task Azure_Command_Is_Expected_Command()
{
var result = await RunModule<AzureCommandModule>();

Assert.That(result.Result.Value.CommandInput, Is.EqualTo("""
az account alias create --name MyName
"""));
Assert.That(result.Result.Value!.CommandInput, Is.EqualTo("""
az account alias create --name MyName
"""));
}

[Test]
public async Task Azure_Command_With_Mandatory_Switch_Conflicting_With_Base_Default_Optional_Switch_Is_Expected_Command()
{
var result = await RunModule<AzureCommandModule2>();

Assert.That(result.Result.Value!.CommandInput, Is.EqualTo("""
az account management-group subscription add --name MyName --subscription MySub
"""));
}

private async Task<CommandResult> GetResult(MySuperSecretToolOptions options)
Expand Down

0 comments on commit 9aa3be9

Please sign in to comment.