Private/Update-AvailbleTerraformVersions.Tests.ps1
BeforeAll { . $PSCommandPath.Replace('.Tests.ps1','.ps1') . $PSScriptRoot/../Class/TerrafunConfig.ps1 } Describe 'Update-AvailbleTerraformVersions.Unit' -Tag Unit { BeforeAll { Function Get-TerraformVersions{} Mock Get-TerraformVersions { return @() } } It 'Should check for new versions if the last check was more than 1 hour ago' { $Config = [TerrafunConfig]::new() $Config.Read() $Config.LastUpdateCheck = Get-Date -Format s (Get-Date).AddMinutes(-61).ToUniversalTime() Update-AvailbleTerraformVersions -Config $Config Should -Invoke -CommandName Get-TerraformVersions -Times 1 } It 'Should not for new versions if the last check was less than 1 hour ago' { $Config = [TerrafunConfig]::new() $Config.Read() $Config.LastUpdateCheck = Get-Date -Format s (Get-Date).AddMinutes(-59).ToUniversalTime() Update-AvailbleTerraformVersions -Config $Config Should -Invoke -CommandName Get-TerraformVersions -Times 0 } } |