Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Invoke-requirement fail if set action is not defined #66

Open
andrescolodrero opened this issue Jun 23, 2020 · 1 comment
Open

Invoke-requirement fail if set action is not defined #66

andrescolodrero opened this issue Jun 23, 2020 · 1 comment

Comments

@andrescolodrero
Copy link

Hi,
following your video i found this:

$requirements = @(
@{

    Describe = 'Folder tempi present in the system'
    Test     = { test-path -path 'c:/temp' }
    #Set      = { new-item -ItemType Directory -Path 'c:/temp'}
}

)

c:/temp still is not created, but the command fail:
pplyRequirement : Failed to apply Requirement 'Folder tempi present in the system'
At C:\Program Files\WindowsPowerShell\Modules\Requirements\2.3.6\src\core.ps1:49 char:23

  • $Requirements | % { applyRequirement $_ }
  •                   ~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,applyRequirement
@jazz127
Copy link

jazz127 commented Jan 31, 2021

I hit this issue as well and wanted to add my observations for you/others that may stumble across this post

Basically, this is expected behavior. I think it would be great if the Readme was clearer in explaining this because we've obviously both missed it.

#54 was my guidance in suggesting that further tests should not be processed so the "apply error" is returned when exiting Invoke-Requirement once the test fails (and can't be remediated due to the lack of Set)

Side note that Test-Requirement does seem to process all Tests regardless of errors but wouldn't help if you want to use Set.

I'm not sure if this should be a separate feature request/post but when using Invoke-Requirement, it might be nice to have the option to suppress errors like this and return a "skipped" state or similar for tests that were not processed after an error occurs.

I think this might help with problems I'm having with format-checklist as well. When a failed requirement occurs the line below returns $null and then I get "Format-Checklist : Cannot index into a null array." when $nextFsm is subsequently used. Interestingly, this occurs even when using Test-Requirement.

$nextFsm = &$nextFsm[$stateVector] @transitionArgs

Not wanting to push my luck but while we are here, maybe even a switch to process all requirements regardless could be provided as well?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants