[Test framework] false-positive with loop within module
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
**Bicep version**
Bicep CLI version 0.24.24 (5646341b0c)
**Describe the bug**
Bicep test issues a message about wrong location of `copyIndex`.
**To Reproduce**
> bicep test .\test.bicep
WARNING: The following experimental Bicep features have been enabled: TestFramework. Experimental features should be enabled for testing purposes only, as there are no guarantees about the quality or stability of these features. Do not enable these settings for any production usage, or your production environment may be subject to breaking.
[-] Evaluation kvs Skipped!
Reason: The template function 'copyIndex' is not expected at this location. The function can only be used in a resource with copy specified. Please see https://aka.ms/arm-resource-loops for usage details.
* `test.bicep`
```bicep
test kvs 'module.bicep' = {
params: {}
}
```
* `module.bicep`
```bicep
var k2ms = loadJsonContent('./data.json')
module kv 'kv.bicep' = [for (k2mItem, i) in k2ms: {
name: 'kv${i}'
params: {
location: 'eastus'
name: k2mItem.name
}
}]
```
* `kv.bicep`
```bicep
param location string
param name string
resource foo 'Microsoft.KeyVault/vaults@2023-07-01' = {
location: location
name: name
properties: {
sku: {
family: 'A'
name: 'standard'
}
tenantId: '00000000-0000-0000-0000-000000000000'
}
}
```
* `data.json`
```json
[
{
"name": "vault"
}
]
```
**Additional context**
Enable test framework:
```json
"testFramework": true
```
Contributor guide
Assessment
This issue has not been assessed yet.