Skip to content

Commit 20c7d17

Browse files
author
Nicholas King
committed
Test location parameter in deleted apps cmdlets
1 parent 6b651cb commit 20c7d17

File tree

7 files changed

+2750
-7887
lines changed

7 files changed

+2750
-7887
lines changed

src/Websites/Websites.Test/ScenarioTests/Common.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function Get-WebLocation
109109
}
110110
}
111111

112-
return "WestUS"
112+
return "West US"
113113
}
114114

115115
<#
@@ -133,7 +133,7 @@ function Get-SecondaryLocation
133133
}
134134
}
135135

136-
return "WestUS"
136+
return "West US"
137137
}
138138

139139
<#

src/Websites/Websites.Test/ScenarioTests/WebAppBackupRestoreTests.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,12 @@ function Test-GetDeletedWebApp
399399
Remove-AzWebAppSlot -ResourceGroupName $rgname -Name $wname -Slot $slotName -Force
400400
Remove-AzWebApp -ResourceGroupName $rgname -Name $wname -Force
401401

402-
$deletedApp = Get-AzDeletedWebApp -ResourceGroupName $rgname -Name $wname -Slot "Production"
402+
$deletedApp = Get-AzDeletedWebApp -ResourceGroupName $rgname -Name $wname -Slot "Production" -Location $location
403403
Assert-NotNull $deletedApp
404404
Assert-AreEqual $rgname $deletedApp.ResourceGroupName
405405
Assert-AreEqual $wname $deletedApp.Name
406406

407-
$deletedSlot = Get-AzDeletedWebApp -ResourceGroupName $rgname -Name $wname -Slot $slotName
407+
$deletedSlot = Get-AzDeletedWebApp -ResourceGroupName $rgname -Name $wname -Slot $slotName -Location $location
408408
Assert-NotNull $deletedSlot
409409
Assert-AreEqual $rgname $deletedSlot.ResourceGroupName
410410
Assert-AreEqual $wname $deletedSlot.Name
@@ -462,14 +462,14 @@ function Test-RestoreDeletedWebAppToExisting
462462
if ($isRecordMode)
463463
{
464464
# Need extra time for restore operation to resolve globally
465-
Start-Sleep -Seconds 300
465+
Start-Sleep -Seconds 900
466466
}
467467

468468
# Test the FromDeletedResourceName parameter set
469469
$restoredSlot = Restore-AzDeletedWebApp -ResourceGroupName $rgname -Name $delName -Slot $delSlot -TargetResourceGroupName $rgname -TargetName $wname -TargetSlot $slotName -Force
470470
if ($isRecordMode)
471471
{
472-
Start-Sleep -Seconds 300
472+
Start-Sleep -Seconds 900
473473
}
474474

475475
Assert-NotNull $restoredApp
@@ -533,7 +533,7 @@ function Test-RestoreDeletedWebAppToNew
533533
if ($isRecordMode)
534534
{
535535
# Need extra time for restore operation to resolve globally, or cleanup will be blocked
536-
Start-Sleep -Seconds 300
536+
Start-Sleep -Seconds 900
537537
}
538538
}
539539
finally

src/Websites/Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppBackupRestoreTests/TestGetDeletedWebApp.json

Lines changed: 408 additions & 5411 deletions
Large diffs are not rendered by default.

src/Websites/Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppBackupRestoreTests/TestRestoreDeletedWebAppToExisting.json

Lines changed: 1454 additions & 1598 deletions
Large diffs are not rendered by default.

src/Websites/Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppBackupRestoreTests/TestRestoreDeletedWebAppToNew.json

Lines changed: 861 additions & 861 deletions
Large diffs are not rendered by default.

src/Websites/Websites/Cmdlets/BackupRestore/GetAzureDeletedWebApp.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,16 @@ public override void ExecuteCmdlet()
5151
{
5252
base.ExecuteCmdlet();
5353

54-
IEnumerable<string> locations = ResourcesClient.GetDeletedSitesLocations();
54+
IEnumerable<string> locations;
55+
if (string.IsNullOrEmpty(Location))
56+
{
57+
locations = ResourcesClient.GetDeletedSitesLocations();
58+
}
59+
else
60+
{
61+
locations = new List<string> { Location };
62+
}
63+
5564
IEnumerable<PSAzureDeletedWebApp> deletedSites = WebsitesClient.GetDeletedSitesFromLocations(locations)
5665
.Where(ds => ds.DeletedSiteId.HasValue)
5766
.Select(ds => new PSAzureDeletedWebApp(ds, DefaultContext.Subscription.Id));
@@ -68,10 +77,6 @@ public override void ExecuteCmdlet()
6877
{
6978
deletedSites = deletedSites.Where(ds => string.Equals(Slot, ds.Slot, StringComparison.InvariantCultureIgnoreCase));
7079
}
71-
if (!string.IsNullOrEmpty(Location))
72-
{
73-
deletedSites = deletedSites.Where(ds => string.Equals(Location, ds.Location, StringComparison.InvariantCultureIgnoreCase));
74-
}
7580

7681
WriteObject(deletedSites, true);
7782
}

src/Websites/Websites/Cmdlets/BackupRestore/RestoreAzureDeletedWebApp.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,16 @@ private string GetDeletedSiteResourceId()
128128
switch (ParameterSetName)
129129
{
130130
case FromDeletedResourceNameParameterSet:
131-
IEnumerable<string> locations = ResourcesClient.GetDeletedSitesLocations();
131+
IEnumerable<string> locations;
132+
if (string.IsNullOrEmpty(Location))
133+
{
134+
locations = ResourcesClient.GetDeletedSitesLocations();
135+
}
136+
else
137+
{
138+
locations = new List<string> { Location };
139+
}
140+
132141
var deletedSites = WebsitesClient.GetDeletedSitesFromLocations(locations).Where(ds =>
133142
{
134143
bool match = string.Equals(ds.ResourceGroup, ResourceGroupName, StringComparison.InvariantCultureIgnoreCase) &&
@@ -137,10 +146,6 @@ private string GetDeletedSiteResourceId()
137146
{
138147
match = match && string.Equals(ds.Slot, Slot, StringComparison.InvariantCultureIgnoreCase);
139148
}
140-
if (!string.IsNullOrEmpty(Location))
141-
{
142-
match = match && string.Equals(ds.GeoRegionName, Location, StringComparison.InvariantCultureIgnoreCase);
143-
}
144149
return match;
145150
});
146151
if (!deletedSites.Any())

0 commit comments

Comments
 (0)