-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathManifest.tests.ps1
More file actions
87 lines (70 loc) · 2.92 KB
/
Manifest.tests.ps1
File metadata and controls
87 lines (70 loc) · 2.92 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
BeforeAll {
Set-Location "$PSScriptRoot/.."
Set-BuildEnvironment -Force
$moduleName = $env:BHProjectName
$manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest
$outputDir = Join-Path -Path $ENV:BHProjectPath -ChildPath 'Output'
$outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName
$outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion
$outputManifestPath = Join-Path -Path $outputModVerDir -Child "$($moduleName).psd1"
$manifestData = Test-ModuleManifest -Path $outputManifestPath -Verbose:$false -ErrorAction Stop -WarningAction SilentlyContinue
$changelogPath = Join-Path -Path $env:BHProjectPath -Child 'CHANGELOG.md'
$changelogVersion = Get-Content $changelogPath | ForEach-Object {
if ($_ -match "^##\s\[(?<Version>(\d+\.){1,3}\d+)\]") {
$changelogVersion = $matches.Version
break
}
}
$script:manifest = $null
}
Describe 'Module manifest' {
Context 'Validation' {
It 'Has a valid manifest' {
$manifestData | Should -Not -BeNullOrEmpty
}
It 'Has a valid name in the manifest' {
$manifestData.Name | Should -Be $moduleName
}
It 'Has a valid root module' {
$manifestData.RootModule | Should -Be "$($moduleName).psm1"
}
It 'Has a valid version in the manifest' {
$manifestData.Version -as [Version] | Should -Not -BeNullOrEmpty
}
It 'Has a valid description' {
$manifestData.Description | Should -Not -BeNullOrEmpty
}
It 'Has a valid author' {
$manifestData.Author | Should -Not -BeNullOrEmpty
}
It 'Has a valid guid' {
{ [guid]::Parse($manifestData.Guid) } | Should -Not -Throw
}
It 'Has a valid copyright' {
$manifestData.CopyRight | Should -Not -BeNullOrEmpty
}
It 'Has a valid version in the changelog' {
$changelogVersion | Should -Not -BeNullOrEmpty
$changelogVersion -as [Version] | Should -Not -BeNullOrEmpty
}
It 'Changelog and manifest versions are the same' {
$changelogVersion -as [Version] | Should -Be ( $manifestData.Version -as [Version] )
}
}
}
Describe 'Git tagging' -Skip {
BeforeAll {
$gitTagVersion = $null
if ($git = Get-Command git -CommandType Application -ErrorAction SilentlyContinue) {
$thisCommit = & $git log --decorate --oneline HEAD~1..HEAD
if ($thisCommit -match 'tag:\s*(\d+(?:\.\d+)*)') { $gitTagVersion = $matches[1] }
}
}
It 'Is tagged with a valid version' {
$gitTagVersion | Should -Not -BeNullOrEmpty
$gitTagVersion -as [Version] | Should -Not -BeNullOrEmpty
}
It 'Matches manifest version' {
$manifestData.Version -as [Version] | Should -Be ( $gitTagVersion -as [Version])
}
}