Skip to content

Commit 1542b15

Browse files
committed
added more module tests
1 parent 20bff2a commit 1542b15

9 files changed

+1278
-8
lines changed

src/Bicep.Core.Samples/Files/Modules_CRLF/main.bicep

+44
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,47 @@ module duplicatesEverywhere 'modulea.bicep' = [for someDuplicate in []: {
174174
arrayParam: [for otherDuplicate in emptyArray: '${someDuplicate}-${otherDuplicate}']
175175
}
176176
}]
177+
178+
module propertyLoopInsideParameterValue 'modulea.bicep' = {
179+
name: 'propertyLoopInsideParameterValue'
180+
params: {
181+
objParam: {
182+
a: [for i in range(0,10): i]
183+
b: [for i in range(1,2): i]
184+
c: {
185+
d: [for j in range(2,3): j]
186+
}
187+
e: [for k in range(4,4): {
188+
f: k
189+
}]
190+
}
191+
stringParamB: ''
192+
arrayParam: [
193+
{
194+
e: [for j in range(7,7): j]
195+
}
196+
]
197+
}
198+
}
199+
200+
module propertyLoopInsideParameterValueInsideModuleLoop 'modulea.bicep' = [for thing in range(0,1): {
201+
name: 'propertyLoopInsideParameterValueInsideModuleLoop'
202+
params: {
203+
objParam: {
204+
a: [for i in range(0,10): i + thing]
205+
b: [for i in range(1,2): i * thing]
206+
c: {
207+
d: [for j in range(2,3): j]
208+
}
209+
e: [for k in range(4,4): {
210+
f: k - thing
211+
}]
212+
}
213+
stringParamB: ''
214+
arrayParam: [
215+
{
216+
e: [for j in range(7,7): j % thing]
217+
}
218+
]
219+
}
220+
}]

src/Bicep.Core.Samples/Files/Modules_CRLF/main.diagnostics.bicep

+43
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,46 @@ module duplicatesEverywhere 'modulea.bicep' = [for someDuplicate in []: {
177177
}
178178
}]
179179

180+
module propertyLoopInsideParameterValue 'modulea.bicep' = {
181+
name: 'propertyLoopInsideParameterValue'
182+
params: {
183+
objParam: {
184+
a: [for i in range(0,10): i]
185+
b: [for i in range(1,2): i]
186+
c: {
187+
d: [for j in range(2,3): j]
188+
}
189+
e: [for k in range(4,4): {
190+
f: k
191+
}]
192+
}
193+
stringParamB: ''
194+
arrayParam: [
195+
{
196+
e: [for j in range(7,7): j]
197+
}
198+
]
199+
}
200+
}
201+
202+
module propertyLoopInsideParameterValueInsideModuleLoop 'modulea.bicep' = [for thing in range(0,1): {
203+
name: 'propertyLoopInsideParameterValueInsideModuleLoop'
204+
params: {
205+
objParam: {
206+
a: [for i in range(0,10): i + thing]
207+
b: [for i in range(1,2): i * thing]
208+
c: {
209+
d: [for j in range(2,3): j]
210+
}
211+
e: [for k in range(4,4): {
212+
f: k - thing
213+
}]
214+
}
215+
stringParamB: ''
216+
arrayParam: [
217+
{
218+
e: [for j in range(7,7): j % thing]
219+
}
220+
]
221+
}
222+
}]

src/Bicep.Core.Samples/Files/Modules_CRLF/main.formatted.bicep

+44
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,47 @@ module duplicatesEverywhere 'modulea.bicep' = [for someDuplicate in []: {
173173
arrayParam: [for otherDuplicate in emptyArray: '${someDuplicate}-${otherDuplicate}']
174174
}
175175
}]
176+
177+
module propertyLoopInsideParameterValue 'modulea.bicep' = {
178+
name: 'propertyLoopInsideParameterValue'
179+
params: {
180+
objParam: {
181+
a: [for i in range(0, 10): i]
182+
b: [for i in range(1, 2): i]
183+
c: {
184+
d: [for j in range(2, 3): j]
185+
}
186+
e: [for k in range(4, 4): {
187+
f: k
188+
}]
189+
}
190+
stringParamB: ''
191+
arrayParam: [
192+
{
193+
e: [for j in range(7, 7): j]
194+
}
195+
]
196+
}
197+
}
198+
199+
module propertyLoopInsideParameterValueInsideModuleLoop 'modulea.bicep' = [for thing in range(0, 1): {
200+
name: 'propertyLoopInsideParameterValueInsideModuleLoop'
201+
params: {
202+
objParam: {
203+
a: [for i in range(0, 10): i + thing]
204+
b: [for i in range(1, 2): i * thing]
205+
c: {
206+
d: [for j in range(2, 3): j]
207+
}
208+
e: [for k in range(4, 4): {
209+
f: k - thing
210+
}]
211+
}
212+
stringParamB: ''
213+
arrayParam: [
214+
{
215+
e: [for j in range(7, 7): j % thing]
216+
}
217+
]
218+
}
219+
}]

src/Bicep.Core.Samples/Files/Modules_CRLF/main.json

+237-1
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,242 @@
10301030
}
10311031
}
10321032
}
1033+
},
1034+
{
1035+
"type": "Microsoft.Resources/deployments",
1036+
"apiVersion": "2019-10-01",
1037+
"name": "propertyLoopInsideParameterValue",
1038+
"properties": {
1039+
"expressionEvaluationOptions": {
1040+
"scope": "inner"
1041+
},
1042+
"mode": "Incremental",
1043+
"parameters": {
1044+
"objParam": {
1045+
"value": {
1046+
"copy": [
1047+
{
1048+
"name": "a",
1049+
"count": "[length(range(0, 10))]",
1050+
"input": "[range(0, 10)[copyIndex('a')]]"
1051+
},
1052+
{
1053+
"name": "b",
1054+
"count": "[length(range(1, 2))]",
1055+
"input": "[range(1, 2)[copyIndex('b')]]"
1056+
},
1057+
{
1058+
"name": "e",
1059+
"count": "[length(range(4, 4))]",
1060+
"input": {
1061+
"f": "[range(4, 4)[copyIndex('e')]]"
1062+
}
1063+
}
1064+
],
1065+
"c": {
1066+
"copy": [
1067+
{
1068+
"name": "d",
1069+
"count": "[length(range(2, 3))]",
1070+
"input": "[range(2, 3)[copyIndex('d')]]"
1071+
}
1072+
]
1073+
}
1074+
}
1075+
},
1076+
"stringParamB": {
1077+
"value": ""
1078+
},
1079+
"arrayParam": {
1080+
"value": [
1081+
{
1082+
"copy": [
1083+
{
1084+
"name": "e",
1085+
"count": "[length(range(7, 7))]",
1086+
"input": "[range(7, 7)[copyIndex('e')]]"
1087+
}
1088+
]
1089+
}
1090+
]
1091+
}
1092+
},
1093+
"template": {
1094+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
1095+
"contentVersion": "1.0.0.0",
1096+
"parameters": {
1097+
"stringParamA": {
1098+
"type": "string",
1099+
"defaultValue": "test"
1100+
},
1101+
"stringParamB": {
1102+
"type": "string"
1103+
},
1104+
"objParam": {
1105+
"type": "object"
1106+
},
1107+
"arrayParam": {
1108+
"type": "array"
1109+
}
1110+
},
1111+
"functions": [],
1112+
"resources": [
1113+
{
1114+
"type": "Mock.Rp/mockResource",
1115+
"apiVersion": "2020-01-01",
1116+
"name": "basicblobs",
1117+
"location": "[parameters('stringParamA')]"
1118+
},
1119+
{
1120+
"type": "Mock.Rp/mockResource",
1121+
"apiVersion": "2020-01-01",
1122+
"name": "myZone",
1123+
"location": "[parameters('stringParamB')]"
1124+
}
1125+
],
1126+
"outputs": {
1127+
"stringOutputA": {
1128+
"type": "string",
1129+
"value": "[parameters('stringParamA')]"
1130+
},
1131+
"stringOutputB": {
1132+
"type": "string",
1133+
"value": "[parameters('stringParamB')]"
1134+
},
1135+
"objOutput": {
1136+
"type": "object",
1137+
"value": "[reference(resourceId('Mock.Rp/mockResource', 'basicblobs'))]"
1138+
},
1139+
"arrayOutput": {
1140+
"type": "array",
1141+
"value": [
1142+
"[resourceId('Mock.Rp/mockResource', 'basicblobs')]",
1143+
"[resourceId('Mock.Rp/mockResource', 'myZone')]"
1144+
]
1145+
}
1146+
}
1147+
}
1148+
}
1149+
},
1150+
{
1151+
"copy": {
1152+
"name": "propertyLoopInsideParameterValueInsideModuleLoop",
1153+
"count": "[length(range(0, 1))]"
1154+
},
1155+
"type": "Microsoft.Resources/deployments",
1156+
"apiVersion": "2019-10-01",
1157+
"name": "propertyLoopInsideParameterValueInsideModuleLoop",
1158+
"properties": {
1159+
"expressionEvaluationOptions": {
1160+
"scope": "inner"
1161+
},
1162+
"mode": "Incremental",
1163+
"parameters": {
1164+
"objParam": {
1165+
"value": {
1166+
"copy": [
1167+
{
1168+
"name": "a",
1169+
"count": "[length(range(0, 10))]",
1170+
"input": "[add(range(0, 10)[copyIndex('a')], range(0, 1)[copyIndex()])]"
1171+
},
1172+
{
1173+
"name": "b",
1174+
"count": "[length(range(1, 2))]",
1175+
"input": "[mul(range(1, 2)[copyIndex('b')], range(0, 1)[copyIndex()])]"
1176+
},
1177+
{
1178+
"name": "e",
1179+
"count": "[length(range(4, 4))]",
1180+
"input": {
1181+
"f": "[sub(range(4, 4)[copyIndex('e')], range(0, 1)[copyIndex()])]"
1182+
}
1183+
}
1184+
],
1185+
"c": {
1186+
"copy": [
1187+
{
1188+
"name": "d",
1189+
"count": "[length(range(2, 3))]",
1190+
"input": "[range(2, 3)[copyIndex('d')]]"
1191+
}
1192+
]
1193+
}
1194+
}
1195+
},
1196+
"stringParamB": {
1197+
"value": ""
1198+
},
1199+
"arrayParam": {
1200+
"value": [
1201+
{
1202+
"copy": [
1203+
{
1204+
"name": "e",
1205+
"count": "[length(range(7, 7))]",
1206+
"input": "[mod(range(7, 7)[copyIndex('e')], range(0, 1)[copyIndex()])]"
1207+
}
1208+
]
1209+
}
1210+
]
1211+
}
1212+
},
1213+
"template": {
1214+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
1215+
"contentVersion": "1.0.0.0",
1216+
"parameters": {
1217+
"stringParamA": {
1218+
"type": "string",
1219+
"defaultValue": "test"
1220+
},
1221+
"stringParamB": {
1222+
"type": "string"
1223+
},
1224+
"objParam": {
1225+
"type": "object"
1226+
},
1227+
"arrayParam": {
1228+
"type": "array"
1229+
}
1230+
},
1231+
"functions": [],
1232+
"resources": [
1233+
{
1234+
"type": "Mock.Rp/mockResource",
1235+
"apiVersion": "2020-01-01",
1236+
"name": "basicblobs",
1237+
"location": "[parameters('stringParamA')]"
1238+
},
1239+
{
1240+
"type": "Mock.Rp/mockResource",
1241+
"apiVersion": "2020-01-01",
1242+
"name": "myZone",
1243+
"location": "[parameters('stringParamB')]"
1244+
}
1245+
],
1246+
"outputs": {
1247+
"stringOutputA": {
1248+
"type": "string",
1249+
"value": "[parameters('stringParamA')]"
1250+
},
1251+
"stringOutputB": {
1252+
"type": "string",
1253+
"value": "[parameters('stringParamB')]"
1254+
},
1255+
"objOutput": {
1256+
"type": "object",
1257+
"value": "[reference(resourceId('Mock.Rp/mockResource', 'basicblobs'))]"
1258+
},
1259+
"arrayOutput": {
1260+
"type": "array",
1261+
"value": [
1262+
"[resourceId('Mock.Rp/mockResource', 'basicblobs')]",
1263+
"[resourceId('Mock.Rp/mockResource', 'myZone')]"
1264+
]
1265+
}
1266+
}
1267+
}
1268+
}
10331269
}
10341270
],
10351271
"outputs": {
@@ -1058,7 +1294,7 @@
10581294
"_generator": {
10591295
"name": "bicep",
10601296
"version": "dev",
1061-
"templateHash": "15175488676486164240"
1297+
"templateHash": "5916075395955971227"
10621298
}
10631299
}
10641300
}

0 commit comments

Comments
 (0)