-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathManifest.tests.ps1
86 lines (69 loc) · 3.18 KB
/
Manifest.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
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
$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"
$changelogPath = Join-Path -Path $env:BHProjectPath -Child 'CHANGELOG.md'
Describe 'Module manifest' {
Context 'Validation' {
$script:manifest = $null
It 'has a valid manifest' {
{
$script:manifest = Test-ModuleManifest -Path $outputManifestPath -Verbose:$false -ErrorAction Stop -WarningAction SilentlyContinue
} | Should Not Throw
}
It 'has a valid name in the manifest' {
$script:manifest.Name | Should Be $env:BHProjectName
}
It 'has a valid root module' {
$script:manifest.RootModule | Should Be "$($moduleName).psm1"
}
It 'has a valid version in the manifest' {
$script:manifest.Version -as [Version] | Should Not BeNullOrEmpty
}
It 'has a valid description' {
$script:manifest.Description | Should Not BeNullOrEmpty
}
It 'has a valid author' {
$script:manifest.Author | Should Not BeNullOrEmpty
}
It 'has a valid guid' {
{
[guid]::Parse($script:manifest.Guid)
} | Should Not throw
}
It 'has a valid copyright' {
$script:manifest.CopyRight | Should Not BeNullOrEmpty
}
$script:changelogVersion = $null
It 'has a valid version in the changelog' {
foreach ($line in (Get-Content $changelogPath)) {
if ($line -match "^##\s\[(?<Version>(\d+\.){1,3}\d+)\]") {
$script:changelogVersion = $matches.Version
break
}
}
$script:changelogVersion | Should Not BeNullOrEmpty
$script:changelogVersion -as [Version] | Should Not BeNullOrEmpty
}
It 'changelog and manifest versions are the same' {
$script:changelogVersion -as [Version] | Should be ( $script:manifest.Version -as [Version] )
}
if (Get-Command git.exe -ErrorAction SilentlyContinue) {
$script:tagVersion = $null
It 'is tagged with a valid version' -skip {
$thisCommit = git.exe log --decorate --oneline HEAD~1..HEAD
if ($thisCommit -match 'tag:\s*(\d+(?:\.\d+)*)') {
$script:tagVersion = $matches[1]
}
$script:tagVersion | Should Not BeNullOrEmpty
$script:tagVersion -as [Version] | Should Not BeNullOrEmpty
}
It 'all versions are the same' {
$script:changelogVersion -as [Version] | Should be ( $script:manifest.Version -as [Version] )
#$script:manifest.Version -as [Version] | Should be ( $script:tagVersion -as [Version] )
}
}
}
}