feat: add script to test parsing
This commit is contained in:
parent
3fb7f0926e
commit
a3471ab94b
48
powershell/test-script.ps1
Normal file
48
powershell/test-script.ps1
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
[CmdletBinding(DefaultParameterSetName = 'Set1')]
|
||||||
|
param (
|
||||||
|
# Mandatory string with alias and validation, positional
|
||||||
|
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = 'Set1')]
|
||||||
|
[Parameter(Position = 2, Mandatory = $false, ParameterSetName = 'Set2')]
|
||||||
|
[Alias('n')]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[ValidateScript({
|
||||||
|
$_ -notlike 'undefined'
|
||||||
|
})]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
# Optional int with default value, validated range
|
||||||
|
[Parameter(ParameterSetName = 'Set1')]
|
||||||
|
[ValidateRange(1, 100)]
|
||||||
|
[int]$Count = 10,
|
||||||
|
|
||||||
|
# Switch parameter
|
||||||
|
[Parameter(ParameterSetName = 'Set1')]
|
||||||
|
[switch]$VerboseMode,
|
||||||
|
|
||||||
|
# Accepts pipeline input by value
|
||||||
|
[Parameter(ValueFromPipeline = $true, ParameterSetName = 'Set2')]
|
||||||
|
[string]$InputObject,
|
||||||
|
|
||||||
|
# Accepts pipeline input by property name
|
||||||
|
[Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Set2')]
|
||||||
|
[string]$Property,
|
||||||
|
|
||||||
|
# Parameter that takes an array
|
||||||
|
[Parameter(ParameterSetName = 'Set1')]
|
||||||
|
[string[]]$Tags,
|
||||||
|
|
||||||
|
# Optional parameter with script block default
|
||||||
|
[Parameter(ParameterSetName = 'Set1')]
|
||||||
|
[datetime]$StartTime = (Get-Date),
|
||||||
|
|
||||||
|
# Mandatory parameter in a different parameter set
|
||||||
|
[Parameter(Mandatory = $true, ParameterSetName = 'Set3')]
|
||||||
|
[ValidateSet('Low', 'Medium', 'High')]
|
||||||
|
[string]$Priority,
|
||||||
|
|
||||||
|
# Nullable type
|
||||||
|
[Parameter(ParameterSetName = 'Set1')]
|
||||||
|
[Nullable[bool]]$IsEnabled
|
||||||
|
)
|
||||||
|
|
||||||
|
process {}
|
@ -32,7 +32,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_powershell_file() {
|
fn test_parse_powershell_file() {
|
||||||
let got = parse_powershell_file("powershell/get-metadata.ps1");
|
let got = parse_powershell_file("powershell/test-script.ps1");
|
||||||
assert!(got.is_ok());
|
assert!(got.is_ok());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user