From b9e6a5391cc26317659187391bddad1600a14eb7 Mon Sep 17 00:00:00 2001 From: Ronny Polley Date: Thu, 10 Oct 2024 09:39:46 +0200 Subject: [PATCH] remove trailing whitespace (#65) additional add a empty line at end for touched files. --- PSSDKMan/PSSDKMan.psd1 | 9 +++-- Tests/Commands.Tests.ps1 | 87 ++++++++++++++++++++-------------------- Tests/Utils.Tests.ps1 | 65 +++++++++++++++--------------- 3 files changed, 82 insertions(+), 79 deletions(-) diff --git a/PSSDKMan/PSSDKMan.psd1 b/PSSDKMan/PSSDKMan.psd1 index 4cdffe8..4e97530 100644 --- a/PSSDKMan/PSSDKMan.psd1 +++ b/PSSDKMan/PSSDKMan.psd1 @@ -1,6 +1,6 @@ -# +# # Module manifest -# +# # Generated by: Ronny Polley # @@ -17,5 +17,6 @@ PowerShellVersion = '5.0' - -} \ No newline at end of file + +} + diff --git a/Tests/Commands.Tests.ps1 b/Tests/Commands.Tests.ps1 index 87d09a5..fdbe939 100644 --- a/Tests/Commands.Tests.ps1 +++ b/Tests/Commands.Tests.ps1 @@ -43,15 +43,15 @@ Describe 'sdk' { BeforeEach { sdk } - + It 'initalize posh-sdk' { Assert-VerifiableMock } - + It 'does not init again' { Assert-MockCalled Initialize-Posh-SDK 0 } - + It 'prints help' { Assert-MockCalled Show-Help 1 } @@ -67,12 +67,12 @@ Describe 'sdk' { $Script:PSDK_FORCE_OFFLINE = $true } - + It 'does not load broadcast message from api' { sdk Assert-MockCalled Test-Available-Broadcast 0 } - + It 'performs default command actions' { sdk Assert-VerifiableMock @@ -92,12 +92,12 @@ Describe 'sdk' { $Script:PSDK_FORCE_OFFLINE = $false } - + It 'does not load broadcast message from api' { sdk offline Assert-MockCalled Test-Available-Broadcast 0 } - + It 'performs offline command actions' { sdk offline Assert-VerifiableMock @@ -114,7 +114,7 @@ Describe 'sdk' { Mock Install-Candidate-Version -verifiable -parameterFilter { $Candidate -eq 'grails' -and $Version -eq '2.2.2' -and $InstallPath -eq '\bla' } } - + It 'checks for new broadcast, inits the Candidate-Cache and calls install-command' { sdk i grails 2.2.2 \bla Assert-VerifiableMock @@ -131,7 +131,7 @@ Describe 'sdk' { Mock Install-Candidate-Version -verifiable -parameterFilter { $Candidate -eq 'grails' -and $Version -eq '2.2.2' -and $InstallPath -eq '' } } - + It 'checks for new broadcast, inits the Candidate-Cache and calls install-command' { sdk install grails 2.2.2 Assert-VerifiableMock @@ -148,7 +148,7 @@ Describe 'sdk' { Mock Uninstall-Candidate-Version -verifiable -parameterFilter { $Candidate -eq 'grails' -and $Version -eq '2.2.2' } } - + It 'checks for new broadcast, inits the Candidate-Cache and calls uninstall-command' { sdk uninstall grails 2.2.2 Assert-VerifiableMock @@ -165,7 +165,7 @@ Describe 'sdk' { Mock Uninstall-Candidate-Version -verifiable -parameterFilter { $Candidate -eq 'grails' -and $Version -eq '2.2.1' } } - + It 'checks for new broadcast, inits the Candidate-Cache and calls uninstall-command' { sdk rm grails 2.2.1 Assert-VerifiableMock @@ -182,7 +182,7 @@ Describe 'sdk' { Mock Show-Candidate-Versions -verifiable -parameterFilter { $Candidate -eq 'grails' } } - + It 'checks for new broadcast, inits the Candidate-Cache and calls list-command' { sdk ls grails Assert-VerifiableMock @@ -199,7 +199,7 @@ Describe 'sdk' { Mock Show-Candidate-Versions -verifiable -parameterFilter { $Candidate -eq 'grails' } } - + It 'checks for new broadcast, inits the Candidate-Cache and calls list-command' { sdk list grails Assert-VerifiableMock @@ -216,7 +216,7 @@ Describe 'sdk' { Mock Use-Candidate-Version -verifiable -parameterFilter { $Candidate -eq 'grails' -and $Version -eq '2.2.1' } } - + It 'checks for new broadcast, inits the Candidate-Cache and calls use-command' { sdk u grails 2.2.1 Assert-VerifiableMock @@ -233,7 +233,7 @@ Describe 'sdk' { Mock Use-Candidate-Version -verifiable -parameterFilter { $Candidate -eq 'grails' -and $Version -eq '2.2.1' } } - + It 'checks for new broadcast, inits the Candidate-Cache and calls use-command' { sdk use grails 2.2.1 Assert-VerifiableMock @@ -250,7 +250,7 @@ Describe 'sdk' { Mock Set-Default-Version -verifiable -parameterFilter { $Candidate -eq 'grails' -and $Version -eq '2.2.1' } } - + It 'checks for new broadcast, inits the Candidate-Cache and calls default-command' { sdk d grails 2.2.1 Assert-VerifiableMock @@ -267,7 +267,7 @@ Describe 'sdk' { Mock Set-Default-Version -verifiable -parameterFilter { $Candidate -eq 'grails' -and $Version -eq '2.2.1' } } - + It 'checks for new broadcast, inits the Candidate-Cache and calls default-command' { sdk default grails 2.2.1 Assert-VerifiableMock @@ -284,7 +284,7 @@ Describe 'sdk' { Mock Show-Current-Version -verifiable -parameterFilter { $Candidate -eq 'grails' } } - + It 'checks for new broadcast, inits the Candidate-Cache and calls current-command' { sdk c grails Assert-VerifiableMock @@ -301,7 +301,7 @@ Describe 'sdk' { Mock Show-Current-Version -verifiable -parameterFilter { $Candidate -eq 'grails' } } - + It 'checks for new broadcast, inits the Candidate-Cache and calls current-command' { sdk current grails Assert-VerifiableMock @@ -318,7 +318,7 @@ Describe 'sdk' { Mock Show-Posh-SDK-Version -verifiable } - + It 'checks for new broadcast, inits the Candidate-Cache and calls version-command' { sdk v Assert-VerifiableMock @@ -335,7 +335,7 @@ Describe 'sdk' { Mock Show-Posh-SDK-Version -verifiable } - + It 'checks for new broadcast, inits the Candidate-Cache and calls version-command' { sdk version Assert-VerifiableMock @@ -352,7 +352,7 @@ Describe 'sdk' { Mock Show-Broadcast-Message -verifiable } - + It 'checks for new broadcast, inits the Candidate-Cache and calls broadcast-command' { sdk b Assert-VerifiableMock @@ -369,7 +369,7 @@ Describe 'sdk' { Mock Show-Broadcast-Message -verifiable } - + It 'checks for new broadcast, inits the Candidate-Cache and calls broadcast-command' { sdk broadcast Assert-VerifiableMock @@ -386,7 +386,7 @@ Describe 'sdk' { Mock Show-Help -verifiable } - + It 'checks for new broadcast, inits the Candidate-Cache and calls help-command' { sdk h Assert-VerifiableMock @@ -403,7 +403,7 @@ Describe 'sdk' { Mock Show-Help -verifiable } - + It 'checks for new broadcast, inits the Candidate-Cache and calls help-command' { sdk help Assert-VerifiableMock @@ -420,7 +420,7 @@ Describe 'sdk' { Mock Set-Offline-Mode -verifiable -parameterFilter { $Flag -eq 'enable' } } - + It 'checks for new broadcast, inits the Candidate-Cache and calls offline-command' { sdk offline enable Assert-VerifiableMock @@ -437,7 +437,7 @@ Describe 'sdk' { Mock Invoke-Self-Update -verifiable } - + It 'checks for new broadcast, inits the Candidate-Cache and calls selfupdate-command' { sdk selfupdate Assert-VerifiableMock @@ -454,7 +454,7 @@ Describe 'sdk' { Mock Clear-Cache -verifiable -parameterFilter { $DataType -eq 'version' } } - + It 'checks for new broadcast, inits the Candidate-Cache and calls flush-command' { sdk flush version Assert-VerifiableMock @@ -642,15 +642,15 @@ Describe 'Uninstall-Candidate-Version' { BeforeEach { Uninstall-Candidate-Version grails 24.3 } - + It 'delete the current-junction' { Test-Path "$Global:PSDK_DIR\grails\current" | Should -Be $false } - + It 'delete the version' { Test-Path "$Global:PSDK_DIR\grails\24.3" | Should -Be $false } - + It "checks different preconditions correctly" { Assert-VerifiableMock } @@ -862,7 +862,7 @@ Describe 'Show-Posh-SDK-Version' { Mock Write-Output -verifiable } - + It 'write the version message to output' { Show-Posh-SDK-Version Assert-VerifiableMock @@ -878,7 +878,7 @@ Describe 'Show-Broadcast-Message' { Mock Write-Output -verifiable } - + It 'Write broadcast message to output' { Show-Broadcast-Message Assert-VerifiableMock @@ -946,7 +946,7 @@ Describe 'Clear-Cache' { Mock Write-Output -verifiable } - + It 'deletes the file and writes flush message' { Clear-Cache candidates Assert-VerifiableMock @@ -960,7 +960,7 @@ Describe 'Clear-Cache' { Mock Write-Warning -verifiable } - + It 'writes warning about non existing file' { Clear-Cache candidates Assert-VerifiableMock @@ -975,7 +975,7 @@ Describe 'Clear-Cache' { Mock Write-Output -verifiable } - + It 'deletes the file and writes flush message' { Clear-Cache broadcast Assert-VerifiableMock @@ -989,7 +989,7 @@ Describe 'Clear-Cache' { Mock Write-Warning -verifiable } - + It 'writes warning about non existing file' { Clear-Cache broadcast Assert-VerifiableMock @@ -1004,7 +1004,7 @@ Describe 'Clear-Cache' { Mock Write-Output -verifiable } - + It 'deletes the file and writes flush message' { Clear-Cache version Assert-VerifiableMock @@ -1018,7 +1018,7 @@ Describe 'Clear-Cache' { Mock Write-Warning -verifiable } - + It 'writes warning about non existing file' { Clear-Cache version Assert-VerifiableMock @@ -1031,7 +1031,7 @@ Describe 'Clear-Cache' { Mock Clear-Directory -verifiable -parameterFilter { $Path -eq 'archives' } } - + It 'cleanup archives directory' { Clear-Cache archives Assert-VerifiableMock @@ -1044,7 +1044,7 @@ Describe 'Clear-Cache' { Mock Clear-Directory -verifiable -parameterFilter { $Path -eq 'temp' } } - + It 'cleanup temp directory' { Clear-Cache temp Assert-VerifiableMock @@ -1060,7 +1060,7 @@ Describe 'Clear-Cache' { BeforeEach { Clear-Cache tmp } - + It 'cleanup temp directory' { Assert-VerifiableMock } @@ -1079,10 +1079,11 @@ Describe 'Show-Help' { Mock Write-Output -verifiable } - + It 'write the help to the output' { Show-Help Assert-VerifiableMock } } } + diff --git a/Tests/Utils.Tests.ps1 b/Tests/Utils.Tests.ps1 index 72c99b2..c5d45c4 100644 --- a/Tests/Utils.Tests.ps1 +++ b/Tests/Utils.Tests.ps1 @@ -1,4 +1,4 @@ -BeforeAll { +BeforeAll { . ..\PSSDKMan\Utils.ps1 . .\TestUtils.ps1 } @@ -12,7 +12,7 @@ Describe 'Test-SDKMAN-API-Version' { Mock Invoke-API-Call { throw 'error' } -parameterFilter { $Path -eq 'app/Version' } Test-SDKMAN-API-Version } - + It 'the error handling set the app in offline mode' { $Script:PSDK_AVAILABLE | Should -Be $false } @@ -32,7 +32,7 @@ Describe 'Test-SDKMAN-API-Version' { Mock Invoke-API-Call { 1.2.2 } -parameterFilter { $Path -eq 'app/Version' } Mock Invoke-Self-Update - Test-SDKMAN-API-Version + Test-SDKMAN-API-Version } It 'do nothing' { @@ -83,7 +83,7 @@ Describe 'Test-SDKMAN-API-Version' { Mock Invoke-API-Call { '1.2.3' } -parameterFilter { $Path -eq 'broker/download/sdkman/version/stable' } Mock Invoke-Self-Update -verifiable - Test-SDKMAN-API-Version + Test-SDKMAN-API-Version } It 'updates self' { @@ -201,7 +201,7 @@ Describe 'Test-New-Posh-SDK-Version-Available' { Mock Invoke-RestMethod { '1.1.1' } -parameterFilter { $Uri -eq 'blub' } } - + It 'returns $false' { $result = Test-New-Posh-SDK-Version-Available $result | Should -Be $false @@ -209,14 +209,14 @@ Describe 'Test-New-Posh-SDK-Version-Available' { } Context 'Version service error' { - BeforeAll { + BeforeAll { $Script:PSDK_VERSION_SERVICE = 'blub' $Script:PSDK_VERSION_PATH = 'TestDrive:VERSION.txt' Set-Content $Script:PSDK_VERSION_PATH '1.1.1' Mock Invoke-RestMethod { throw 'error' } -parameterFilter { $Uri -eq 'blub' } } - + It 'returns $false' { $result = Test-New-Posh-SDK-Version-Available $result | Should -Be $false @@ -226,8 +226,8 @@ Describe 'Test-New-Posh-SDK-Version-Available' { Describe 'Get-SDKMAN-API-Version' { Context 'No cached version' { - BeforeAll { - $Script:PSDK_API_VERSION_PATH = 'TestDrive:version.txt' + BeforeAll { + $Script:PSDK_API_VERSION_PATH = 'TestDrive:version.txt' } It 'returns `$null' { @@ -282,13 +282,13 @@ Describe 'Test-Available-Broadcast' { Mock Write-Online-Broadcast } - + It 'does announce offline mode' { Test-Available-Broadcast Assert-MockCalled Write-Offline-Broadcast 1 Assert-MockCalled Write-Online-Broadcast 0 } - + It 'does not call Resolve-Broadcast' { Test-Available-Broadcast Assert-MockCalled Resolve-Broadcast 0 @@ -306,13 +306,13 @@ Describe 'Test-Available-Broadcast' { Mock Write-Online-Broadcast } - + It 'does not announce any mode changes' { Test-Available-Broadcast Assert-MockCalled Write-Offline-Broadcast 0 Assert-MockCalled Write-Online-Broadcast 0 } - + It 'does not call Resolve-Broadcast' { Test-Available-Broadcast Assert-MockCalled Resolve-Broadcast 0 @@ -330,13 +330,13 @@ Describe 'Test-Available-Broadcast' { Mock Write-Online-Broadcast } - + It 'does announce online mode' { Test-Available-Broadcast Assert-MockCalled Write-Offline-Broadcast 0 Assert-MockCalled Write-Online-Broadcast 1 } - + It 'calls Resolve-Broadcast' { Test-Available-Broadcast Assert-VerifiableMock @@ -399,7 +399,7 @@ Describe 'Test-Candidate-Present checks if candidate parameter is valid' { It 'throws an error if no candidate is provided' { { Test-Candidate-Present } | Should -Throw } - + It 'throws error if candidate unknown' { $Script:SDK_CANDIDATES = @('grails', 'groovy') { Test-Candidate-Present java } | Should -Throw @@ -496,7 +496,7 @@ Describe 'Test-Candidate-Version-Available select or vadidates a version for a c Mock Invoke-API-Call { return 2.2 } -parameterFilter { $Path -eq 'candidates/default/grails' } } - + It 'the API default is returned' { $result = Test-Candidate-Version-Available grails $result | Should -Be 2.2 @@ -515,12 +515,12 @@ Describe 'Test-Candidate-Version-Available select or vadidates a version for a c Mock-Api-Call-Grails-1.1.1-Available $true } - + It 'returns the version' { $result = Test-Candidate-Version-Available grails 1.1.1 $result | Should -Be 1.1.1 } - + It 'check candidate parameter' { Test-Candidate-Version-Available grails 1.1.1 Assert-VerifiableMock @@ -623,7 +623,7 @@ Describe 'Test-Candidate-Version-Locally-Available throws error message if not a } Context 'Version is available' { - + It 'not throws any error' { Mock-Grails-1.1.1-Locally-Available $true { Test-Candidate-Version-Locally-Available grails 1.1.1 } | Should -Not -Throw @@ -639,7 +639,7 @@ Describe 'Test-Is-Candidate-Version-Locally-Available check the path exists' { } Context 'COC path for grails 1.1.1 is missing' { - + it 'returns $false' { Mock-PSDK-Dir Test-Is-Candidate-Version-Locally-Available grails 1.1.1 | Should -Be $false @@ -649,7 +649,7 @@ Describe 'Test-Is-Candidate-Version-Locally-Available check the path exists' { } Context 'COC path for grails 1.1.1 exists' { - + it 'returns $true' { Mock-PSDK-Dir New-Item -ItemType Directory "$Global:PSDK_DIR\grails\1.1.1" | Out-Null @@ -738,7 +738,7 @@ Describe 'Set-Junction-Via-Mklink' { } It 'creates a junction to the target location' { - (Get-Junction-Target "$Global:PSDK_DIR\grails\bla").FullName -eq "$Global:PSDK_DIR\grails\1.3.7" + (Get-Junction-Target "$Global:PSDK_DIR\grails\bla").FullName -eq "$Global:PSDK_DIR\grails\1.3.7" } AfterAll { @@ -804,7 +804,7 @@ Describe 'Get-Junction-Target' { Describe 'Get-Online-Mode check the state variables for PSDK-API availablitiy and for force offline mode' { Context 'PSDK-Api unavailable but may be connected' { - + It 'returns $false' { $Script:PSDK_AVAILABLE = $false $Script:PSDK_FORCE_OFFLINE = $false @@ -813,7 +813,7 @@ Describe 'Get-Online-Mode check the state variables for PSDK-API availablitiy an } Context 'PSDK-Api unavailable and may not be connected' { - + It 'returns $false' { $Script:PSDK_AVAILABLE = $false $Script:PSDK_FORCE_OFFLINE = $true @@ -822,7 +822,7 @@ Describe 'Get-Online-Mode check the state variables for PSDK-API availablitiy an } Context 'PSDK-Api is available and may not be connected' { - + It 'returns $false' { $Script:PSDK_AVAILABLE = $true $Script:PSDK_FORCE_OFFLINE = $true @@ -831,7 +831,7 @@ Describe 'Get-Online-Mode check the state variables for PSDK-API availablitiy an } Context 'PSDK-Api is available and may be connected' { - + It 'returns $true' { $Script:PSDK_AVAILABLE = $true $Script:PSDK_FORCE_OFFLINE = $false @@ -843,7 +843,7 @@ Describe 'Get-Online-Mode check the state variables for PSDK-API availablitiy an Describe 'Test-Online-Mode throws an error when offline' { Context 'Offline' { - + It 'throws an error' { Mock Get-Online-Mode { return $false } { Test-Online-Mode } | Should -Throw @@ -851,7 +851,7 @@ Describe 'Test-Online-Mode throws an error when offline' { } Context 'Online' { - + It 'throws no error' { Mock Get-Online-Mode { return $true } { Test-Online-Mode } | Should -Not -Throw @@ -861,7 +861,7 @@ Describe 'Test-Online-Mode throws an error when offline' { Describe 'Invoke-API-Call helps doing calls to the PSDK-Api' { Context 'Successful API call only with API path' { - + It 'returns the result from Invoke-RestMethod' { $Script:PSDK_SERVICE = 'blub' Mock Invoke-RestMethod { 'called' } -parameterFilter { $Uri -eq 'blub/na/rock' } @@ -1167,7 +1167,7 @@ Describe 'Write-Offline-Version-List' { Mock Get-Current-Candidate-Version { 1.1.1 } -parameterFilter { $Candidate -eq 'grails' } Mock Get-Installed-Candidate-Version-List { 1.1.1, 2.2.2, 2.3.0 } -parameterFilter { $Candidate -eq 'grails' } } - + It 'Outputs 11 lines' { Write-Offline-Version-List grails Assert-MockCalled Write-Output 11 @@ -1183,7 +1183,7 @@ Describe 'Write-Version-List' { Mock Get-Installed-Candidate-Version-List { return '1.1.1', '2.2.2', '2.3.0' } -parameterFilter { $Candidate -eq 'grails' } Mock Invoke-API-Call { 'bla' } -parameterFilter { $Path -eq 'candidates/grails/cygwin/versions/list?current=1.1.1&installed=1.1.1,2.2.2,2.3.0' } } - + It 'writes to host' { Write-Version-List grails Assert-MockCalled Write-Output 1 @@ -1330,3 +1330,4 @@ Describe 'Install-Remote-Version' { } } } +