Skip to content

Commit d50b219

Browse files
author
dragonfly91
committed
Splitting get container and vault tests into separate files
1 parent fb008b4 commit d50b219

9 files changed

+204
-67
lines changed

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@
126126
<Compile Include="ScenarioTests\AzureBackupTests.cs" />
127127
<Compile Include="ScenarioTests\AzureBackupTestBase.cs" />
128128
<Compile Include="Properties\AssemblyInfo.cs" />
129+
<Compile Include="ScenarioTests\GetAzureBackupContainerTests.cs" />
130+
<Compile Include="ScenarioTests\GetAzureBackupVaultCredentialsTests.cs" />
131+
<Compile Include="ScenarioTests\SetAzureBackupVaultStorageTypeTests.cs" />
129132
</ItemGroup>
130133
<ItemGroup>
131134
<ProjectReference Include="..\..\..\Common\Commands.Common\Commands.Common.csproj">
@@ -154,6 +157,9 @@
154157
<None Include="ScenarioTests\AzureBackupTests.ps1">
155158
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
156159
</None>
160+
<None Include="ScenarioTests\GetAzureBackupContainerTests.ps1" />
161+
<None Include="ScenarioTests\GetAzureBackupVaultCredentialsTests.ps1" />
162+
<None Include="ScenarioTests\SetAzureBackupVaultStorageTypeTests.ps1" />
157163
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\BackUpAzureBackUpItem.json" />
158164
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\DisableAzureBackupProtectionTest.json" />
159165
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\EnableAzureBackupProtectionTest.json" />

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupTests.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,5 @@ public void BackUpAzureBackUpItem()
6565
{
6666
this.RunPowerShellTest("BackUpAzureBackUpItemTest");
6767
}
68-
69-
[Fact]
70-
public void GetAzureBackupContainerTests()
71-
{
72-
this.RunPowerShellTest("Test-GetAzureBackupContainerWithoutFilterReturnsNonZeroContainers");
73-
74-
this.RunPowerShellTest("Test-GetAzureBackupContainerWithUniqueFilterReturnsOneContainer");
75-
}
76-
77-
[Fact]
78-
public void GetAzureBackupVaultCredentialsTests()
79-
{
80-
this.RunPowerShellTest("Test-GetAzureBackupVaultCredentialsReturnsFileNameAndDownloadsCert");
81-
}
82-
83-
[Fact]
84-
public void SetAzureBackupVaultStorageTypeTests()
85-
{
86-
this.RunPowerShellTest("Test-SetAzureBackupVaultStorageTypeWithFreshResourceDoesNotThrowException");
87-
88-
this.RunPowerShellTest("Test-SetAzureBackupVaultStorageTypeWithLockedResourceThrowsException");
89-
}
9068
}
9169
}

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupTests.ps1

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ $Location = "SouthEast Asia"
2424
$PolicyName = "Policy9";
2525
$PolicyId = "c87bbada-6e1b-4db2-b76c-9062d28959a4";
2626
$POName = "iaasvmcontainer;dev01testing;dev01testing"
27-
$CertTargetLocation = (Get-Item -Path ".\" -Verbose).FullName;
2827

2928
<#
3029
.SYNOPSIS
@@ -187,47 +186,3 @@ function Test-StopAzureBackupJob
187186
$jobDetails = Get-AzureBackupJobDetails -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Job $jobsList[0];
188187
#Assert-AreEqual 'Cancelling' $jobDetails.Status
189188
}
190-
191-
function Test-GetAzureBackupContainerWithoutFilterReturnsNonZeroContainers
192-
{
193-
$containers = Get-AzureBackupContainer -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location
194-
Assert-NotNull $containers 'Container list should not be null';
195-
}
196-
197-
function Test-GetAzureBackupContainerWithUniqueFilterReturnsOneContainer
198-
{
199-
$container = Get-AzureBackupContainer -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -ContainerResourceGroupName $ContainerResourceGroupName -ContainerResourceName $ContainerResourceName
200-
Assert-NotNull $container 'Container should not be null';
201-
Assert-AreEqual $container.ResourceName $ContainerResourceName -CaseSensitive 'Returned container resource name (a.k.a friendly name) does not match the test VM resource name';
202-
Assert-AreEqual $container.ResourceGroupName $ContainerResourceGroupName -CaseSensitive 'Returned container resource group name (a.k.a parent friendly name) does not match the test VM resource group name';
203-
}
204-
205-
function Test-GetAzureBackupVaultCredentialsReturnsFileNameAndDownloadsCert
206-
{
207-
$fileName = Get-AzureBackupVaultCredentials -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -TargetLocation $CertTargetLocation
208-
Assert-NotNull $fileName 'File name should not be null';
209-
$certFileFullPath = [io.path]::combine($CertTargetLocation, $fileName);
210-
Assert-True {{ Test-Path $certFileFullPath }}
211-
}
212-
213-
function Test-SetAzureBackupVaultStorageTypeWithFreshResourceDoesNotThrowException
214-
{
215-
# TODO: Create a new resource and use it for these calls. At the end, delete it.
216-
217-
Set-AzureBackupVaultStorageType -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Type GeoRedundant
218-
219-
Set-AzureBackupVaultStorageType -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Type LocallyRedundant
220-
221-
Set-AzureBackupVaultStorageType -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Type GeoRedundant
222-
223-
Set-AzureBackupVaultStorageType -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Type LocallyRedundant
224-
}
225-
226-
function Test-SetAzureBackupVaultStorageTypeWithLockedResourceThrowsException
227-
{
228-
# One of them is bound to fail
229-
230-
Assert-Throws { Set-AzureBackupVaultStorageType -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Type GeoRedundant }
231-
232-
Assert-Throws { Set-AzureBackupVaultStorageType -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Type LocallyRedundant }
233-
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Collections.Generic;
17+
using System.Linq;
18+
using System.Text;
19+
using System.Threading.Tasks;
20+
using Xunit;
21+
22+
namespace Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests
23+
{
24+
public class GetAzureBackupContainerTests : AzureBackupTestsBase
25+
{
26+
[Fact]
27+
public void GetAzureBackupContainerTests()
28+
{
29+
this.RunPowerShellTest("Test-GetAzureBackupContainerWithoutFilterReturnsNonZeroContainers");
30+
31+
this.RunPowerShellTest("Test-GetAzureBackupContainerWithUniqueFilterReturnsOneContainer");
32+
}
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
$ResourceGroupName = "backuprg"
16+
$ResourceName = "backuprn"
17+
$Location = "SouthEast Asia"
18+
$ContainerResourceGroupName = "dev01Testing"
19+
$ContainerResourceName = "dev01Testing"
20+
21+
function Test-GetAzureBackupContainerWithoutFilterReturnsNonZeroContainers
22+
{
23+
$containers = Get-AzureBackupContainer -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location
24+
Assert-NotNull $containers 'Container list should not be null';
25+
}
26+
27+
function Test-GetAzureBackupContainerWithUniqueFilterReturnsOneContainer
28+
{
29+
$container = Get-AzureBackupContainer -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -ContainerResourceGroupName $ContainerResourceGroupName -ContainerResourceName $ContainerResourceName
30+
Assert-NotNull $container 'Container should not be null';
31+
Assert-AreEqual $container.ResourceName $ContainerResourceName -CaseSensitive 'Returned container resource name (a.k.a friendly name) does not match the test VM resource name';
32+
Assert-AreEqual $container.ResourceGroupName $ContainerResourceGroupName -CaseSensitive 'Returned container resource group name (a.k.a parent friendly name) does not match the test VM resource group name';
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Collections.Generic;
17+
using System.Linq;
18+
using System.Text;
19+
using System.Threading.Tasks;
20+
using Xunit;
21+
22+
namespace Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests
23+
{
24+
public class GetAzureBackupVaultCredentialsTests : AzureBackupTestsBase
25+
{
26+
[Fact]
27+
public void GetAzureBackupVaultCredentialsTests()
28+
{
29+
this.RunPowerShellTest("Test-GetAzureBackupVaultCredentialsReturnsFileNameAndDownloadsCert");
30+
}
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
$ResourceGroupName = "backuprg"
16+
$ResourceName = "backuprn"
17+
$Location = "SouthEast Asia"
18+
$CertTargetLocation = (Get-Item -Path ".\" -Verbose).FullName;
19+
20+
function Test-GetAzureBackupVaultCredentialsReturnsFileNameAndDownloadsCert
21+
{
22+
$fileName = Get-AzureBackupVaultCredentials -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -TargetLocation $CertTargetLocation
23+
Assert-NotNull $fileName 'File name should not be null';
24+
$certFileFullPath = [io.path]::combine($CertTargetLocation, $fileName);
25+
Assert-True {{ Test-Path $certFileFullPath }}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Collections.Generic;
17+
using System.Linq;
18+
using System.Text;
19+
using System.Threading.Tasks;
20+
using Xunit;
21+
22+
namespace Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests
23+
{
24+
public class SetAzureBackupVaultStorageTypeTests : AzureBackupTestsBase
25+
{
26+
[Fact]
27+
public void SetAzureBackupVaultStorageTypeTests()
28+
{
29+
this.RunPowerShellTest("Test-SetAzureBackupVaultStorageTypeWithFreshResourceDoesNotThrowException");
30+
31+
this.RunPowerShellTest("Test-SetAzureBackupVaultStorageTypeWithLockedResourceThrowsException");
32+
}
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
$ResourceGroupName = "backuprg"
16+
$ResourceName = "backuprn"
17+
$Location = "SouthEast Asia"
18+
19+
function Test-SetAzureBackupVaultStorageTypeWithFreshResourceDoesNotThrowException
20+
{
21+
# TODO: Create a new resource and use it for these calls. At the end, delete it.
22+
23+
Set-AzureBackupVaultStorageType -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Type GeoRedundant
24+
25+
Set-AzureBackupVaultStorageType -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Type LocallyRedundant
26+
27+
Set-AzureBackupVaultStorageType -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Type GeoRedundant
28+
29+
Set-AzureBackupVaultStorageType -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Type LocallyRedundant
30+
}
31+
32+
function Test-SetAzureBackupVaultStorageTypeWithLockedResourceThrowsException
33+
{
34+
# One of them is bound to fail
35+
36+
Assert-Throws { Set-AzureBackupVaultStorageType -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Type GeoRedundant }
37+
38+
Assert-Throws { Set-AzureBackupVaultStorageType -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Type LocallyRedundant }
39+
}

0 commit comments

Comments
 (0)