Skip to content

Commit 43be860

Browse files
Made it so file path isn't needed when only activate is on
1 parent 49fb96f commit 43be860

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

src/ResourceManager/AzureBatch/Commands.Batch.Test/Applications/NewBatchApplicationPackageCommandTests.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,21 @@ public void UploadBatchApplicationPackageTest()
6868

6969
[Fact]
7070
[Trait(Category.AcceptanceType, Category.CheckIn)]
71-
public void ActivateApplicationPackage()
71+
public void ActivateApplicationPackageOnly()
7272
{
7373
string accountName = "account01";
7474
string resourceGroup = "resourceGroup";
7575
string applicationId = "applicationId";
76-
string filePath = "~/fake/filepath";
7776
string version = "version";
7877
string format = "zip";
7978

8079
PSApplicationPackage applicationPackageResponse = new PSApplicationPackage();
8180

82-
batchClientMock.Setup(b => b.UploadAndActivateApplicationPackage(resourceGroup, accountName, applicationId, version, filePath, format, true)).Returns(applicationPackageResponse);
81+
batchClientMock.Setup(b => b.UploadAndActivateApplicationPackage(resourceGroup, accountName, applicationId, version, null, format, true)).Returns(applicationPackageResponse);
8382

8483
cmdlet.AccountName = accountName;
8584
cmdlet.ResourceGroupName = resourceGroup;
8685
cmdlet.ApplicationId = applicationId;
87-
cmdlet.FilePath = filePath;
8886
cmdlet.ApplicationVersion = version;
8987
cmdlet.Format = format;
9088
cmdlet.ActivateOnly = true;
@@ -93,7 +91,7 @@ public void ActivateApplicationPackage()
9391
commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
9492
cmdlet.ExecuteCmdlet();
9593

96-
batchClientMock.Verify(b => b.UploadAndActivateApplicationPackage(resourceGroup, accountName, applicationId, version, filePath, format, true), Times.Once());
94+
batchClientMock.Verify(b => b.UploadAndActivateApplicationPackage(resourceGroup, accountName, applicationId, version, null, format, true), Times.Once());
9795
}
9896
}
9997
}

src/ResourceManager/AzureBatch/Commands.Batch/Applications/NewBatchApplicationPackageCommand.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ public class NewBatchApplicationPackageCommand : BatchCmdletBase
3838
[ValidateNotNullOrEmpty]
3939
public string ApplicationVersion { get; set; }
4040

41-
[Parameter(Position = 4, ValueFromPipelineByPropertyName = true, Mandatory = true, HelpMessage = "Specifies the file to be uploaded as the application package binary file.")]
41+
[Parameter(Position = 4, ValueFromPipelineByPropertyName = true, Mandatory = true, HelpMessage = "Specifies the format of the application package binary file.")]
4242
[ValidateNotNullOrEmpty]
43-
public string FilePath { get; set; }
43+
public string Format { get; set; }
4444

45-
[Parameter(Position = 5, ValueFromPipelineByPropertyName = true, Mandatory = true, HelpMessage = "Specifies the format of the application package binary file.")]
45+
[Parameter(ValueFromPipelineByPropertyName = true)]
4646
[ValidateNotNullOrEmpty]
47-
public string Format { get; set; }
47+
public string FilePath { get; set; }
4848

49-
[Parameter(Position = 6, ValueFromPipelineByPropertyName = true)]
49+
[Parameter(ValueFromPipelineByPropertyName = true)]
5050
[ValidateNotNullOrEmpty]
5151
public SwitchParameter ActivateOnly { get; set; }
5252

src/ResourceManager/AzureBatch/Commands.Batch/Models/BatchClient.Applications.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,25 +171,24 @@ public virtual PSApplicationPackage UploadAndActivateApplicationPackage(
171171
string format,
172172
bool activateOnly)
173173
{
174-
// Checks File path and resourceGroupName is valid
175-
if (!File.Exists(filePath))
176-
{
177-
throw new FileNotFoundException(string.Format(Resources.FileNotFound, filePath), filePath);
178-
}
179-
180174
if (string.IsNullOrEmpty(resourceGroupName))
181175
{
182176
// use resource mgr to see if account exists and then use resource group name to do the actual lookup
183177
resourceGroupName = GetGroupForAccount(accountName);
184178
}
185-
186-
// If the package has already been uploaded but wasn't activated.
187179
if (activateOnly)
188180
{
181+
// If the package has already been uploaded but wasn't activated.
189182
ActivateApplicationPackage(resourceGroupName, accountName, applicationId, version, format, Resources.FailedToActivate);
190183
}
191184
else
192185
{
186+
// Checks File path and resourceGroupName is valid
187+
if (!File.Exists(filePath))
188+
{
189+
throw new FileNotFoundException(string.Format(Resources.FileNotFound, filePath), filePath);
190+
}
191+
193192
// Else create Application Package and upload.
194193
bool appPackageAlreadyExists;
195194

0 commit comments

Comments
 (0)