Skip to content

Commit 2806d82

Browse files
committed
Fix test failure if ElasticPoolCollection is null
1 parent 4b8b0e1 commit 2806d82

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

src/ResourceManager/Sql/Commands.Sql/ServerUpgrade/Cmdlet/StartAzureSqlServerUpgrade.cs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,25 +86,28 @@ public class StartAzureSqlServerUpgrade : AzureSqlServerUpgradeCmdletBase<AzureS
8686
/// <returns>The generated model from user input</returns>
8787
protected override IEnumerable<AzureSqlServerUpgradeStartModel> ApplyUserInputToModel(IEnumerable<AzureSqlServerUpgradeStartModel> models)
8888
{
89-
// Ignore user input and recalculate StorageMb based on Dtu and coefficient of the edition
90-
foreach (var elasticPoolProperties in ElasticPoolCollection)
89+
if (ElasticPoolCollection != null)
9190
{
92-
switch (elasticPoolProperties.Edition.ToLower())
91+
// Ignore user input and recalculate StorageMb based on Dtu and coefficient of the edition
92+
foreach (var elasticPoolProperties in ElasticPoolCollection)
9393
{
94-
case "basic":
95-
elasticPoolProperties.StorageMb = elasticPoolProperties.Dtu*StorageMbPerDtuBasic;
96-
break;
97-
case "standard":
98-
elasticPoolProperties.StorageMb = elasticPoolProperties.Dtu * StorageMbPerDtuStandard;
99-
break;
100-
case "premium":
101-
elasticPoolProperties.StorageMb = elasticPoolProperties.Dtu * StorageMbPerDtuPremium;
102-
break;
103-
default:
104-
throw new PSArgumentException(string.Format("Edition {0} is invalid", elasticPoolProperties.Edition));
94+
switch (elasticPoolProperties.Edition.ToLower())
95+
{
96+
case "basic":
97+
elasticPoolProperties.StorageMb = elasticPoolProperties.Dtu * StorageMbPerDtuBasic;
98+
break;
99+
case "standard":
100+
elasticPoolProperties.StorageMb = elasticPoolProperties.Dtu * StorageMbPerDtuStandard;
101+
break;
102+
case "premium":
103+
elasticPoolProperties.StorageMb = elasticPoolProperties.Dtu * StorageMbPerDtuPremium;
104+
break;
105+
default:
106+
throw new PSArgumentException(string.Format("Edition {0} is invalid", elasticPoolProperties.Edition));
107+
}
108+
105109
}
106-
107-
}
110+
}
108111

109112
var newEntity = new List<AzureSqlServerUpgradeStartModel>();
110113
newEntity.Add(new AzureSqlServerUpgradeStartModel

0 commit comments

Comments
 (0)