正如测试所说,我想测试文件夹是否包含子文件夹或 rbac.jsonc 文件。当我在本地运行时,此处的测试工作正常,但是当我提交它时,管道失败,因为此测试失败。
它所指的文件夹包含名为“.subscription”的子文件夹,因此我应该通过测试。文件夹结构应该不是问题,因为我可以确定它正在寻找正确的位置,只是没有找到子文件夹?
我不明白它如何在本地工作而不是在管道中工作?如果 ($SubDirectories.Count -eq 0) 出于某种原因,它必须在这条线附近它无法计算子目录
It "Checks that folders contains either a subfolder or an rbac.jsonc file" {
$queue = [System.Collections.Queue]::new()
$InvalidFolders = [System.Collections.Generic.List[PSobject]]::new()
$Directories = Get-ChildItem -path $topMgFolderPath -Exclude '.policy', '.bicep' -Directory
$Directories | ForEach-Object { $queue.Enqueue($_.FullName) }
while ($Queue.Count -gt 0) {
$dir = $queue.Dequeue()
$HasRbacFile = Test-Path -Path "$dir/rbac.jsonc"
if ($HasRbacFile) {
Continue
}
$SubDirectories = Get-ChildItem -path $dir -Exclude '.policy', '.bicep' -Directory
if ($SubDirectories.Count -eq 0) {
$InvalidFolders += $dir
}
else {
$SubDirectories | ForEach-Object { $queue.Enqueue($_.FullName) }
}
}
$InvalidFolders | should -BeNullOrEmpty
}