Skip to content

Commit d758d1a

Browse files
committed
Update how path is constructed for file used in Resources tests
1 parent 6d64050 commit d758d1a

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/RoleDefinitionTests.ps1

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ function Test-RoleDefinitionCreateTests
2121
# Setup
2222
# Basic positive case - read from file
2323
$rdName = 'CustomRole Tests Role'
24-
New-AzureRmRoleDefinitionWithId -InputFile "$TestOutputRoot\Resources\NewRoleDefinition.json" -RoleDefinitionId ee78fa8a-3cdd-418e-a4d8-949b57a33dcd
24+
$inputFilePath = Join-Path -Path $TestOutputRoot -ChildPath Resources\NewRoleDefinition.json
25+
New-AzureRmRoleDefinitionWithId -InputFile $inputFilePath -RoleDefinitionId ee78fa8a-3cdd-418e-a4d8-949b57a33dcd
2526

2627
$rd = Get-AzureRmRoleDefinition -Name $rdName
2728
Assert-AreEqual "Test role" $rd.Description
@@ -70,7 +71,8 @@ function Test-RdNegativeScenarios
7071
$badIdException = "Cannot find role definition with id '" + $rdId + "'."
7172

7273
# Throws on trying to update the a role that does not exist
73-
Assert-Throws { Set-AzureRmRoleDefinition -InputFile "$TestOutputRoot\Resources\RoleDefinition.json" } $badIdException
74+
$inputFilePath = Join-Path -Path $TestOutputRoot -ChildPath Resources\RoleDefinition.json
75+
Assert-Throws { Set-AzureRmRoleDefinition -InputFile $inputFilePath } $badIdException
7476

7577
# Role Defintion not provided.
7678
$roleDefNotProvided = "Parameter set cannot be resolved using the specified named parameters."
@@ -84,7 +86,7 @@ function Test-RdNegativeScenarios
8486
# Role not provided.
8587
$roleDefNotProvided = "Cannot validate argument on parameter 'Role'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
8688
Assert-Throws { Set-AzureRmRoleDefinition -Role $rdNull } $roleDefNotProvided
87-
Assert-Throws { Set-AzureRmRoleDefinition -InputFile "$TestOutputRoot\Resources\RoleDefinition.json" -Role $rd } $roleDefNotProvided
89+
Assert-Throws { Set-AzureRmRoleDefinition -InputFile $inputFilePath -Role $rd } $roleDefNotProvided
8890

8991
#TODO add check for valid input file and valid role
9092

@@ -103,7 +105,8 @@ function Test-RDPositiveScenarios
103105
# Setup
104106
# Create a role definition with Name rdNamme.
105107
$rdName = 'Another tests role'
106-
$rd = New-AzureRmRoleDefinitionWithId -InputFile "$TestOutputRoot\Resources\RoleDefinition.json" -RoleDefinitionId 0a0e83bc-50b9-4c4d-b2c2-3f41e1a8baf2
108+
$inputFilePath = Join-Path -Path $TestOutputRoot -ChildPath Resources\RoleDefinition.json
109+
$rd = New-AzureRmRoleDefinitionWithId -InputFile $inputFilePath -RoleDefinitionId 0a0e83bc-50b9-4c4d-b2c2-3f41e1a8baf2
107110
$rd = Get-AzureRmRoleDefinition -Name $rdName
108111

109112
# Update the role definition with action that was created in the step above.
@@ -129,7 +132,8 @@ function Test-RDUpdate
129132

130133
# Create a role definition with Name rdNamme.
131134
$rdName = 'Another tests role'
132-
$rd = New-AzureRmRoleDefinitionWithId -InputFile "$TestOutputRoot\Resources\RoleDefinition.json" -RoleDefinitionId 3d95b97a-5745-4c39-950c-0b608dea635f
135+
$inputFilePath = Join-Path -Path $TestOutputRoot -ChildPath Resources\RoleDefinition.json
136+
$rd = New-AzureRmRoleDefinitionWithId -InputFile $inputFilePath -RoleDefinitionId 3d95b97a-5745-4c39-950c-0b608dea635f
133137
$rd = Get-AzureRmRoleDefinition -Name $rdName
134138

135139
# Update the role definition with action that was created in the step above.
@@ -158,7 +162,8 @@ function Test-RDCreateFromFile
158162
$badScopeException = "Exception calling `"ExecuteCmdlet`" with `"0`" argument(s): `"Scope '/subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/ResourceGroups' should have even number of parts.`""
159163
try
160164
{
161-
$rd = New-AzureRmRoleDefinitionWithId -InputFile "$TestOutputRoot\Resources\InvalidRoleDefinition.json" -RoleDefinitionId 4482e4d1-8757-4d67-b3c1-5c8ccee3fdcc
165+
$inputFilePath = Join-Path -Path $TestOutputRoot -ChildPath Resources\InvalidRoleDefinition.json
166+
$rd = New-AzureRmRoleDefinitionWithId -InputFile $inputFilePath -RoleDefinitionId 4482e4d1-8757-4d67-b3c1-5c8ccee3fdcc
162167
Assert-AreEqual "This assertion shouldn't be hit'" "New-AzureRmRoleDefinition should've thrown an exception"
163168
}
164169
catch
@@ -280,7 +285,8 @@ function Test-RoleDefinitionDataActionsCreateTests
280285
# Setup
281286
# Basic positive case - read from file
282287
$rdName = 'CustomRole Tests Role New'
283-
New-AzureRmRoleDefinitionWithId -InputFile "$TestOutputRoot\Resources\DataActionsRoleDefinition.json" -RoleDefinitionId e3efe8c9-d9ae-4f0e-838d-57ce43068a13
288+
$inputFilePath = Join-Path -Path $TestOutputRoot -ChildPath Resources\DataActionsRoleDefinition.json
289+
New-AzureRmRoleDefinitionWithId -InputFile $inputFilePath -RoleDefinitionId e3efe8c9-d9ae-4f0e-838d-57ce43068a13
284290

285291
$rd = Get-AzureRmRoleDefinition -Name $rdName
286292
Assert-AreEqual "Test role" $rd.Description
@@ -322,7 +328,8 @@ function Test-RDGetCustomRoles
322328
# Setup
323329
# Basic positive case - read from file
324330
$rdName = 'Another tests role'
325-
$rd = New-AzureRmRoleDefinitionWithId -InputFile "$TestOutputRoot\Resources\RoleDefinition.json" -RoleDefinitionId 3d95b97a-5745-4c39-950c-0b608dea635f
331+
$inputFilePath = Join-Path -Path $TestOutputRoot -ChildPath Resources\RoleDefinition.json
332+
$rd = New-AzureRmRoleDefinitionWithId -InputFile $inputFilePath -RoleDefinitionId 3d95b97a-5745-4c39-950c-0b608dea635f
326333
$rd = Get-AzureRmRoleDefinition -Name $rdName
327334

328335
$roles = Get-AzureRmRoleDefinition -Custom
@@ -437,7 +444,8 @@ function Test-RDDataActionsNegativeTestCases
437444
# Setup
438445
# Basic positive case - read from file
439446
$rdName = 'Another tests role'
440-
$rd = New-AzureRmRoleDefinitionWithId -InputFile "$TestOutputRoot\Resources\RoleDefinition.json" -RoleDefinitionId 3d95b97a-5745-4c39-950c-0b608dea635f
447+
$inputFilePath = Join-Path -Path $TestOutputRoot -ChildPath Resources\RoleDefinition.json
448+
$rd = New-AzureRmRoleDefinitionWithId -InputFile $inputFilePath -RoleDefinitionId 3d95b97a-5745-4c39-950c-0b608dea635f
441449
$rd = Get-AzureRmRoleDefinition -Name $rdName
442450

443451
$createdRole = Get-AzureRmRoleDefinition -Name $rdName

0 commit comments

Comments
 (0)