Skip to content

Commit 74286ef

Browse files
author
EwanNoble
committed
Fix for a single element object array and more tests
1 parent 7af59fa commit 74286ef

File tree

5 files changed

+40
-7
lines changed

5 files changed

+40
-7
lines changed

tasks/EnvironmentConfiguration/task/ps_modules/Handlers/private/schema/Get-SchemaProperty.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function Get-SchemaProperty {
4444

4545
'AsArray' {
4646
$ArrayString = Get-VstsTaskVariable -Name $VariableName
47-
$TaskVariable = $ArrayString | ConvertFrom-Json
47+
$TaskVariable = @($ArrayString | ConvertFrom-Json)
4848
break
4949
}
5050

tasks/EnvironmentConfiguration/tests/modules/UnitTest.Helpers.psm1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ function Set-MockEnvironment {
1313
$ENV:PaymentsInt = "1"
1414
$ENV:PaymentsNumber = "1.0"
1515
$ENV:PaymentsArray = @"
16-
[{"one":"value"}, {"two": "value"}, {"three":"value"}]
16+
["one","two","three"]
17+
"@
18+
$ENV:PaymentsObjectArray = @"
19+
[{"Enabled": true, "aString": "string"}]
1720
"@
1821

1922
}

tasks/EnvironmentConfiguration/tests/resource/SFA.DAS.Test.Invalid.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
},
66
"PaymentsEnabled": "true",
77
"PaymentsNumber": 1.0,
8-
"PaymentsArray": [
9-
"one",
10-
"two",
11-
"three"
8+
"PaymentsArray": {
9+
"one": "one",
10+
"two": "two",
11+
"three": "three"
12+
},
13+
"PaymentsObjectArray": [
14+
"wrong"
1215
]
1316
}

tasks/EnvironmentConfiguration/tests/resource/SFA.DAS.Test.Valid.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,11 @@
1111
"two",
1212
"three"
1313
],
14-
"PaymentsBlankDefault": ""
14+
"PaymentsBlankDefault": "",
15+
"PaymentsObjectArray": [
16+
{
17+
"Enabled": true,
18+
"aString": "string"
19+
}
20+
]
1521
}

tasks/EnvironmentConfiguration/tests/resource/SFA.DAS.Test.schema.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,27 @@
5454
"PaymentsBlankDefault": {
5555
"type": "string",
5656
"default": ""
57+
},
58+
"PaymentsObjectArray": {
59+
"type": "array",
60+
"items": {
61+
"type": "object",
62+
"properties": {
63+
"Enabled": {
64+
"type": "boolean"
65+
},
66+
"aString": {
67+
"type": "string"
68+
}
69+
},
70+
"additionalProperties": false,
71+
"required": [
72+
"Enabled",
73+
"aString"
74+
]
75+
},
76+
"minItems": 0,
77+
"environmentVariable": "PaymentsObjectArray"
5778
}
5879
},
5980
"additionalProperties": false,

0 commit comments

Comments
 (0)