Skip to content

Commit be48054

Browse files
committed
New-AzBatchTask should allow empty command line
- This fixes #9938.
1 parent 44c86d9 commit be48054

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/Batch/Batch.Test/Tasks/NewBatchTaskCommandTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void NewBatchTaskShouldHaveExpectedMandatoryProperties()
6363

6464
cmdlet.JobId = "job-1";
6565

66-
Assert.Throws<ArgumentNullException>(() => cmdlet.ExecuteCmdlet());
66+
var e = Assert.Throws<ArgumentNullException>(() => cmdlet.ExecuteCmdlet());
6767

6868
cmdlet.Id = "testTask";
6969

@@ -78,9 +78,11 @@ public void NewBatchTaskShouldHaveExpectedMandatoryProperties()
7878
cmdlet.ExecuteCmdlet();
7979
}
8080

81-
[Fact]
81+
[Theory]
82+
[InlineData("cmd /c echo hello")]
83+
[InlineData("")]
8284
[Trait(Category.AcceptanceType, Category.CheckIn)]
83-
public void NewBatchTaskParametersGetPassedToRequestTest()
85+
public void NewBatchTaskParametersGetPassedToRequestTest(string commandline)
8486
{
8587
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
8688
cmdlet.BatchContext = context;
@@ -90,7 +92,7 @@ public void NewBatchTaskParametersGetPassedToRequestTest()
9092
cmdlet.AffinityInformation = new PSAffinityInformation("affinityValue");
9193
cmdlet.DisplayName = "display name";
9294
cmdlet.Constraints = new PSTaskConstraints(TimeSpan.FromHours(1), TimeSpan.FromDays(2), 5);
93-
cmdlet.CommandLine = "cmd /c echo hello";
95+
cmdlet.CommandLine = commandline;
9496
cmdlet.EnvironmentSettings = new Dictionary<string, string>();
9597
cmdlet.EnvironmentSettings.Add("env1", "value1");
9698
cmdlet.MultiInstanceSettings = new PSMultiInstanceSettings("cmd /c echo coordinating", 3)

src/Batch/Batch/Tasks/NewBatchTaskCommand.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System;
16-
using Microsoft.Azure.Batch;
17-
using Microsoft.Azure.Commands.Batch.Models;
1816
using System.Collections;
19-
using System.Collections.Generic;
20-
using System.Linq;
2117
using System.Management.Automation;
22-
using Constants = Microsoft.Azure.Commands.Batch.Utils.Constants;
18+
using Microsoft.Azure.Batch;
19+
using Microsoft.Azure.Commands.Batch.Models;
2320

2421
namespace Microsoft.Azure.Commands.Batch
2522
{
@@ -55,7 +52,6 @@ public class NewBatchTaskCommand : BatchObjectModelCmdletBase
5552

5653
[Parameter(ParameterSetName = JobIdAndSingleAddParameterSet, Mandatory = true)]
5754
[Parameter(ParameterSetName = JobObjectAndSingleAddParameterSet, Mandatory = true)]
58-
[ValidateNotNullOrEmpty]
5955
public string CommandLine { get; set; }
6056

6157
[Parameter(ParameterSetName = JobIdAndSingleAddParameterSet)]

0 commit comments

Comments
 (0)