Skip to content

Commit 78f32ee

Browse files
authored
Merge pull request #148 from NJLangley/bug-147
Fixes for bug 147
2 parents a8a561f + 23acfc5 commit 78f32ee

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

private/ConvertFrom-OrderedHashTablesToArrays.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ function ConvertFrom-OrderedHashTablesToArrays {
2424

2525
Write-Verbose "Converting ordered hash table to array";
2626

27-
# First convert each item in the array to have ordered hashtables instead of arrays if required
27+
# First convert each item in the array to have arrays instead of ordered hashtables if required
2828
for ($i=0; $i -lt $Item.$prop.Count; $i++ ){
2929
$Item.$prop[$i] = ConvertFrom-OrderedHashTablesToArrays -Item $Item.$prop[$i];
3030
}
31-
# Then convert the actual array to a ordered hashtables
31+
# Then convert the actual ordered hashtables back to an array
3232

3333
# Without the ForEach-Object we get a OrderedDictionaryKeyValueCollection back, which is not too useful. We need an array, or the JSON
3434
# gets saved using the keys as properties instead of an array. The foreeach unboxes back to an array for us.
35-
$Item.$prop = $Item.$prop.Values | ForEach-Object { $_ };
35+
$Item.$prop = @($Item.$prop.Values | ForEach-Object { $_ });
3636
}
3737
elseif ( $Item.$prop.GetType().Name -eq "PSCustomObject" ) {
3838
Write-Verbose "Converting PSCustomObject property using a recursive function call...";

test/BigFactorySample2/pipeline/Multiple Waits.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@
5454
"waitTimeInSeconds": 3
5555
}
5656
}
57+
],
58+
"ifFalseActivities": [
59+
{
60+
"name": "Wait 5",
61+
"type": "Wait",
62+
"dependsOn": [],
63+
"userProperties": [],
64+
"typeProperties": {
65+
"waitTimeInSeconds": 2
66+
}
67+
}
5768
]
5869
}
5970
},

test/Update-PropertiesFromFile.Tests.ps1

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ InModuleScope azure.datafactory.tools {
199199

200200
Context 'When called and CSV has array indexers in object name column' {
201201
It 'Should complete' {
202-
# Changing activity names means we can index into it if another test already ran, so reload the files
202+
# Changing activity names means we cant index into it if another test already ran, so reload the files
203203
Copy-Item -Path "$SrcFolder" -Destination "$TmpFolder" -Filter "*.*" -Recurse:$true -Force
204204
$script:adf = Import-AdfFromFolder -FactoryName "xyz" -RootFolder "$RootFolder"
205205
$script:option = New-AdfPublishOption
@@ -220,7 +220,7 @@ InModuleScope azure.datafactory.tools {
220220
}
221221
Context 'When called and CSV has array indexers in object name column' {
222222
It 'Should update properties of correct activities' {
223-
# Changing activity names means we can index into it if another test already ran, so reload the files
223+
# Changing activity names means we cant index into it if another test already ran, so reload the files
224224
Copy-Item -Path "$SrcFolder" -Destination "$TmpFolder" -Filter "*.*" -Recurse:$true -Force
225225
$script:adf = Import-AdfFromFolder -FactoryName "xyz" -RootFolder "$RootFolder"
226226
$script:option = New-AdfPublishOption
@@ -229,10 +229,18 @@ InModuleScope azure.datafactory.tools {
229229
Update-PropertiesFromFile -adf $script:adf -stage "array"
230230
$t = Get-AdfObjectByName -adf $script:adf -name "Multiple Waits" -type "Pipeline"
231231
$t.Body.properties.activities[0].name | Should -Be "Wait Number 1"
232+
233+
# New check for correct type on arrays passed back. Make sure arrays with multiple elements are not boxed up again (Issue #147)
234+
$t.Body.properties.activities[1].typeProperties.ifTrueActivities.GetType().BaseType.Name | Should -Be "Array"
235+
$t.Body.properties.activities[1].typeProperties.ifTrueActivities[0].GetType().BaseType.Name | Should -Be "Object"
236+
$t.Body.properties.activities[1].typeProperties.ifFalseActivities.GetType().BaseType.Name | Should -Be "Array"
237+
$t.Body.properties.activities[1].typeProperties.ifTrueActivities[0].GetType().BaseType.Name | Should -Be "Object"
238+
232239
$t.Body.properties.activities[1].typeProperties.ifTrueActivities[0].name | Should -Be "Wait Number 2"
233240
$t.Body.properties.activities[1].typeProperties.ifTrueActivities[0].typeProperties.waitTimeInSeconds | Should -Be 22
234241
$t.Body.properties.activities[1].typeProperties.ifTrueActivities[1].name | Should -Be "Wait Number 3"
235242
$t.Body.properties.activities[1].typeProperties.ifTrueActivities[1].typeProperties.waitTimeInSeconds | Should -Be 33
243+
236244
$t.Body.properties.activities[2].name | Should -Be "Wait Number 4"
237245
}
238246
}

0 commit comments

Comments
 (0)