mirror of
https://github.com/actions/runner-images.git
synced 2025-12-12 12:06:59 +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
|
[String] $Version
|
||||||
|
|
||||||
ToolVersionNode([String] $ToolName, [String] $Version): base($ToolName) {
|
ToolVersionNode([String] $ToolName, [String] $Version): base($ToolName) {
|
||||||
|
|
||||||
|
if ([String]::IsNullOrEmpty($Version)) {
|
||||||
|
throw "ToolVersionNode '$($this.ToolName)' has empty version"
|
||||||
|
}
|
||||||
|
|
||||||
$this.Version = $Version
|
$this.Version = $Version
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,6 +201,11 @@ class ToolVersionsListNode: BaseToolNode {
|
|||||||
|
|
||||||
ToolVersionsListNode([String] $ToolName, [String[]] $Versions, [String] $MajorVersionRegex, [String] $ListType): base($ToolName) {
|
ToolVersionsListNode([String] $ToolName, [String[]] $Versions, [String] $MajorVersionRegex, [String] $ListType): base($ToolName) {
|
||||||
$this.Versions = $Versions
|
$this.Versions = $Versions
|
||||||
|
|
||||||
|
if ([String]::IsNullOrEmpty($Versions)) {
|
||||||
|
throw "ToolVersionsListNode '$($this.ToolName)' has empty versions list"
|
||||||
|
}
|
||||||
|
|
||||||
$this.MajorVersionRegex = [Regex]::new($MajorVersionRegex)
|
$this.MajorVersionRegex = [Regex]::new($MajorVersionRegex)
|
||||||
$this.ListType = $ListType
|
$this.ListType = $ListType
|
||||||
$this.ValidateMajorVersionRegex()
|
$this.ValidateMajorVersionRegex()
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ Describe "Nodes.UnitTests" {
|
|||||||
|
|
||||||
It "Deserialization" {
|
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 = ""; 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
|
{ [ToolVersionNode]::FromJsonObject(@{ NodeType = "ToolVersionNode"; ToolName = "MyTool"; Version = "2.1.3" }) } | Should -Not -Throw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user