tests/ShareSitecore.Backup/Public/SharedSitecore.Backup.Tests.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
$repoPath = Split-Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) -Parent Write-Verbose "repoPath:$repoPath" . $repoPath\tests\TestRunner.ps1 { $repoPath = Split-Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) -Parent . $repoPath\tests\TestUtils.ps1 $ModuleName = Split-Path $repoPath -Leaf $ModuleScriptName = 'SharedSitecore.Backup.psm1' $ModuleManifestName = 'SharedSitecore.Backup.psd1' $ModuleScriptPath = "$repoPath\src\$ModuleName\$ModuleScriptName" $ModuleManifestPath = "$repoPath\src\$\ModuleName\$ModuleManifestName" if (!(Get-Module PSScriptAnalyzer -ErrorAction SilentlyContinue)) { Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Force } Describe 'Module Tests' { $repoPath = Split-Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) -Parent $ModuleName = Split-Path $repoPath -Leaf $ModuleScriptName = "$ModuleName.psm1" #$ModuleManifestName = 'SharedSitecore.Backup.psd1' $ModuleScriptPath = "$repoPath\src\$ModuleName\$ModuleScriptName" #$ModuleManifestPath = "$PSScriptRoot\..\..\src\$ModuleManifestName" It 'imports successfully' { $repoPath = Split-Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) -Parent $ModuleName = Split-Path $repoPath -Leaf #$ModuleScriptName = 'SharedSitecore.Backup.psm1' #$ModuleManifestName = 'SharedSitecore.Backup.psd1' $ModuleScriptPath = "$repoPath\src\$ModuleName\$ModuleName.psm1" #$ModuleManifestPath = "$PSScriptRoot\..\..\src\$ModuleManifestName" Write-Verbose "Import-Module -Name $($ModuleScriptPath)" { Import-Module -Name $ModuleScriptPath -ErrorAction Stop } | Should -Not -Throw } It 'passes default PSScriptAnalyzer rules' { $repoPath = Split-Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) -Parent $ModuleName = Split-Path $repoPath -Leaf #$ModuleScriptName = 'SharedSitecore.Backup.psm1' $ModuleScriptPath = "$repoPath\src\$ModuleName\$ModuleName.psm1" Invoke-ScriptAnalyzer -Path $ModuleScriptPath | Should -BeNullOrEmpty } } Describe 'Module Manifest Tests' { It 'passes Test-ModuleManifest' { $repoPath = Split-Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) -Parent $ModuleName = Split-Path $repoPath -Leaf $ModuleManifestName = "$ModuleName.psd1" $ModuleManifestPath = "$repoPath\src\$ModuleName\$ModuleManifestName" Write-Output $ModuleManifestPath Test-ModuleManifest -Path $ModuleManifestPath | Should -Not -BeNullOrEmpty $? | Should -Be $true } } } |