mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-11 03:57:29 +00:00
report Tool nodes with null or empty versions (#8154)
This commit is contained in:
@@ -161,6 +161,11 @@ class ToolVersionNode: BaseToolNode {
|
||||
[String] $Version
|
||||
|
||||
ToolVersionNode([String] $ToolName, [String] $Version): base($ToolName) {
|
||||
|
||||
if ([String]::IsNullOrEmpty($Version)) {
|
||||
throw "ToolVersionNode '$($this.ToolName)' has empty version"
|
||||
}
|
||||
|
||||
$this.Version = $Version
|
||||
}
|
||||
|
||||
@@ -196,6 +201,11 @@ class ToolVersionsListNode: BaseToolNode {
|
||||
|
||||
ToolVersionsListNode([String] $ToolName, [String[]] $Versions, [String] $MajorVersionRegex, [String] $ListType): base($ToolName) {
|
||||
$this.Versions = $Versions
|
||||
|
||||
if ([String]::IsNullOrEmpty($Versions)) {
|
||||
throw "ToolVersionsListNode '$($this.ToolName)' has empty versions list"
|
||||
}
|
||||
|
||||
$this.MajorVersionRegex = [Regex]::new($MajorVersionRegex)
|
||||
$this.ListType = $ListType
|
||||
$this.ValidateMajorVersionRegex()
|
||||
|
||||
@@ -26,7 +26,7 @@ Describe "Nodes.UnitTests" {
|
||||
|
||||
It "Deserialization" {
|
||||
{ [ToolVersionNode]::FromJsonObject(@{ NodeType = "ToolVersionNode"; ToolName = ""; Version = "2.1.3" }) } | Should -Throw '*Exception setting "ToolName": "The argument is null or empty.*'
|
||||
{ [ToolVersionNode]::FromJsonObject(@{ NodeType = "ToolVersionNode"; ToolName = "MyTool"; Version = "" }) } | Should -Throw '*Exception setting "Version": "The argument is null or empty.*'
|
||||
{ [ToolVersionNode]::FromJsonObject(@{ NodeType = "ToolVersionNode"; ToolName = "MyTool"; Version = "" }) } | Should -Throw 'ToolVersionNode ''MyTool'' has empty version'
|
||||
{ [ToolVersionNode]::FromJsonObject(@{ NodeType = "ToolVersionNode"; ToolName = "MyTool"; Version = "2.1.3" }) } | Should -Not -Throw
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user