| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -7,17 +7,13 @@ Import-Module (Join-Path $PSScriptRoot "../helpers/pester-extensions.psm1")
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					Import-Module (Join-Path $PSScriptRoot "../helpers/common-helpers.psm1")
 | 
					 | 
					 | 
					 | 
					Import-Module (Join-Path $PSScriptRoot "../helpers/common-helpers.psm1")
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					function Get-UseGoLogs {
 | 
					 | 
					 | 
					 | 
					function Get-UseGoLogs {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    $homeDir = $env:HOME
 | 
					 | 
					 | 
					 | 
					    # GitHub Windows images don't have `HOME` variable
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if ([string]::IsNullOrEmpty($homeDir)) {
 | 
					 | 
					 | 
					 | 
					    $homeDir = $env:HOME ?? $env:HOMEDRIVE
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        # GitHub Windows images don't have `HOME` variable
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $homeDir = $env:HOMEDRIVE
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    $logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages" -Resolve
 | 
					 | 
					 | 
					 | 
					    $logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages" -Resolve
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    $useGoLogFile = Get-ChildItem -Path $logsFolderPath | Where-Object {
 | 
					 | 
					 | 
					 | 
					    $useGoLogFile = Get-ChildItem -Path $logsFolderPath | Where-Object {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $logContent = Get-Content $_.Fullname -Raw
 | 
					 | 
					 | 
					 | 
					        $logContent = Get-Content $_.Fullname -Raw
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return $logContent -match "GoTool"
 | 
					 | 
					 | 
					 | 
					        return $logContent -match "setup-go@v"
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | Select-Object -First 1
 | 
					 | 
					 | 
					 | 
					    } | Select-Object -First 1
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return $useGoLogFile.Fullname
 | 
					 | 
					 | 
					 | 
					    return $useGoLogFile.Fullname
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -28,18 +24,17 @@ Describe "Go" {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    It "version is correct" {
 | 
					 | 
					 | 
					 | 
					    It "version is correct" {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $versionOutput = Invoke-Expression -Command "go version"
 | 
					 | 
					 | 
					 | 
					        $versionOutput = Invoke-Expression "go --version"
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $finalVersion = $Version.ToString(3)
 | 
					 | 
					 | 
					 | 
					        $versionOutput | Should -Match $Version
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        If ($Version.Build -eq "0"){
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            $finalVersion = $Version.ToString(2)
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $versionOutput | Should -Match $finalVersion
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    It "is used from tool-cache" {
 | 
					 | 
					 | 
					 | 
					    It "is used from tool-cache" {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $goPath = (Get-Command "go").Path
 | 
					 | 
					 | 
					 | 
					        $goPath = (Get-Command "go").Path
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $goPath | Should -Not -BeNullOrEmpty
 | 
					 | 
					 | 
					 | 
					        $goPath | Should -Not -BeNullOrEmpty
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $expectedPath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath "go"
 | 
					 | 
					 | 
					 | 
					        
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        # GitHub Windows images don't have `AGENT_TOOLSDIRECTORY` variable
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        $toolcacheDir = $env:AGENT_TOOLSDIRECTORY ?? $env:RUNNER_TOOL_CACHE
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        $expectedPath = Join-Path -Path $toolcacheDir -ChildPath "go"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $goPath.startsWith($expectedPath) | Should -BeTrue -Because "'$goPath' is not started with '$expectedPath'"
 | 
					 | 
					 | 
					 | 
					        $goPath.startsWith($expectedPath) | Should -BeTrue -Because "'$goPath' is not started with '$expectedPath'"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -48,33 +43,6 @@ Describe "Go" {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $useGoLogFile = Get-UseGoLogs
 | 
					 | 
					 | 
					 | 
					        $useGoLogFile = Get-UseGoLogs
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $useGoLogFile | Should -Exist
 | 
					 | 
					 | 
					 | 
					        $useGoLogFile | Should -Exist
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $useGoLogContent = Get-Content $useGoLogFile -Raw
 | 
					 | 
					 | 
					 | 
					        $useGoLogContent = Get-Content $useGoLogFile -Raw
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $useGoLogContent | Should -Match "Found tool in cache"
 | 
					 | 
					 | 
					 | 
					        $useGoLogContent | Should -Match "Found cache"
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    Set-Location -Path "source"
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    $sourceLocation = Get-Location
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    It "Run simple code" {
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $simpleLocation = Join-Path -Path $sourceLocation -ChildPath "simple"
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Set-Location -Path $simpleLocation
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        "go run simple.go" | Should -ReturnZeroExitCode
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        "go build simple.go" | Should -ReturnZeroExitCode
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        "./simple" | Should -ReturnZeroExitCode
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    It "Run maps code" {
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $mapsLocation = Join-Path -Path $sourceLocation -ChildPath "maps"
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Set-Location -Path $mapsLocation
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        "go run maps.go" | Should -ReturnZeroExitCode
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        "go build maps.go" | Should -ReturnZeroExitCode
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        "./maps" | Should -ReturnZeroExitCode
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    It "Run methods code" {
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $methodsLocation = Join-Path -Path $sourceLocation -ChildPath "methods"
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Set-Location -Path $methodsLocation
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        "go run methods.go" | Should -ReturnZeroExitCode
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        "go build methods.go" | Should -ReturnZeroExitCode
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        "./methods" | Should -ReturnZeroExitCode
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 |