| 
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -7,17 +7,13 @@ Import-Module (Join-Path $PSScriptRoot "../helpers/pester-extensions.psm1")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				Import-Module (Join-Path $PSScriptRoot "../helpers/common-helpers.psm1")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				function Get-UseGoLogs {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    $homeDir = $env:HOME
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    if ([string]::IsNullOrEmpty($homeDir)) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    # GitHub Windows images don't have `HOME` variable
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        $homeDir = $env:HOMEDRIVE
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    $homeDir = $env:HOME ?? $env:HOMEDRIVE
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    $logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages" -Resolve
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    $useGoLogFile = Get-ChildItem -Path $logsFolderPath | Where-Object {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        $logContent = Get-Content $_.Fullname -Raw
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        return $logContent -match "GoTool"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        return $logContent -match "setup-go@v"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    } | Select-Object -First 1
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    return $useGoLogFile.Fullname
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -28,18 +24,17 @@ Describe "Go" {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    It "version is correct" {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        $versionOutput = Invoke-Expression -Command "go version"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        $finalVersion = $Version.ToString(3)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        If ($Version.Build -eq "0"){
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            $finalVersion = $Version.ToString(2)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        $versionOutput | Should -Match $finalVersion
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        $versionOutput = Invoke-Expression "go --version"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        $versionOutput | Should -Match $Version
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    It "is used from tool-cache" {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        $goPath = (Get-Command "go").Path
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        $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'"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -48,33 +43,6 @@ Describe "Go" {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        $useGoLogFile = Get-UseGoLogs
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        $useGoLogFile | Should -Exist
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        $useGoLogContent = Get-Content $useGoLogFile -Raw
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        $useGoLogContent | Should -Match "Found tool in 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
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        $useGoLogContent | Should -Match "Found cache"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 |