Skip to content

Commit c6a012e

Browse files
committed
Add regression tests for build.psd1 parameters
1 parent 704e1fd commit c6a012e

File tree

10 files changed

+133
-0
lines changed

10 files changed

+133
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#requires -Module ModuleBuilder
2+
. $PSScriptRoot\..\Convert-FolderSeparator.ps1
3+
4+
Describe "Parameters.Set in build manifest" -Tag Integration {
5+
BeforeAll {
6+
New-Item $PSScriptRoot\Result3\Parameters\ReadMe.md -ItemType File -Force
7+
$Output = Build-Module $PSScriptRoot\Parameters\build.psd1
8+
if ($Output) {
9+
$Module = [IO.Path]::ChangeExtension($Output.Path, "psm1")
10+
$Metadata = Import-Metadata $Output.Path
11+
}
12+
}
13+
14+
It "Passthru works" {
15+
$Output | Should -Not -BeNullOrEmpty
16+
}
17+
18+
It "The Target is Build" {
19+
"$PSScriptRoot\Result3\Parameters\ReadMe.md" | Should -Exist
20+
}
21+
22+
It "The version is set" {
23+
$Metadata.ModuleVersion | Should -Be "3.0.0"
24+
}
25+
26+
It "The PreRelease is set" {
27+
$Metadata.PrivateData.PSData.Prerelease | Should -Be 'alpha001'
28+
}
29+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
@{
2+
# The module version should be SemVer.org compatible
3+
ModuleVersion = "1.0.0"
4+
5+
# PrivateData is where all third-party metadata goes
6+
PrivateData = @{
7+
# PrivateData.PSData is the PowerShell Gallery data
8+
PSData = @{
9+
# Prerelease string should be here, so we can set it
10+
Prerelease = ''
11+
12+
# Release Notes have to be here, so we can update them
13+
ReleaseNotes = '
14+
A test module
15+
'
16+
17+
# Tags applied to this module. These help with module discovery in online galleries.
18+
Tags = 'Authoring','Build','Development','BestPractices'
19+
20+
# A URL to the license for this module.
21+
LicenseUri = 'https://github.com/PoshCode/ModuleBuilder/blob/master/LICENSE'
22+
23+
# A URL to the main website for this project.
24+
ProjectUri = 'https://github.com/PoshCode/ModuleBuilder'
25+
26+
# A URL to an icon representing this module.
27+
IconUri = 'https://github.com/PoshCode/ModuleBuilder/blob/resources/ModuleBuilder.png?raw=true'
28+
} # End of PSData
29+
} # End of PrivateData
30+
31+
# The main script module that is automatically loaded as part of this module
32+
RootModule = 'Parameters.psm1'
33+
34+
# Modules that must be imported into the global environment prior to importing this module
35+
RequiredModules = @()
36+
37+
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
38+
DefaultCommandPrefix = 'Param'
39+
40+
# Always define FunctionsToExport as an empty @() which will be replaced on build
41+
FunctionsToExport = @()
42+
AliasesToExport = @()
43+
44+
# ID used to uniquely identify this module
45+
GUID = 'a264e183-e0f7-4219-bc80-c30d14e0e98e'
46+
Description = 'A module for authoring and building PowerShell modules'
47+
48+
# Common stuff for all our modules:
49+
CompanyName = 'PoshCode'
50+
Author = 'Joel Bennett'
51+
Copyright = "Copyright 2024 Joel Bennett"
52+
53+
# Minimum version of the Windows PowerShell engine required by this module
54+
PowerShellVersion = '5.1'
55+
CompatiblePSEditions = @('Core','Desktop')
56+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using module ModuleBuilder
2+
3+
function GetFinale {
4+
[CmdletBinding()]
5+
# [Alias("gf")]
6+
param()
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
New-Alias -Name 'Get-MyAlias' -Value 'Get-ChildItem'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using module ModuleBuilder
2+
3+
function GetPreview {
4+
[CmdletBinding()]
5+
# [Alias("gp")]
6+
param()
7+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function TestUnExportedAliases {
2+
[CmdletBinding()]
3+
param()
4+
5+
New-Alias -Name 'New-NotExportedAlias1' -Value 'Write-Verbose'
6+
Set-Alias -Name 'New-NotExportedAlias2' -Value 'Write-Verbose'
7+
}
8+
9+
New-Alias -Name 'New-NotExportedAlias3' -Value 'Write-Verbose' -Scope Global
10+
Set-Alias -Name 'New-NotExportedAlias4' -Value 'Write-Verbose' -Scope Global
11+
12+
New-Alias -Name 'New-NotExportedAlias5' -Value 'Write-Verbose'
13+
Remove-Alias -Name 'New-NotExportedAlias5'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using module ModuleBuilder
2+
3+
function Get-Source {
4+
[CmdletBinding()]
5+
[Alias("gs","gsou")]
6+
param()
7+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function Set-Source {
2+
[CmdletBinding()]
3+
[Alias("ss", "ssou")]
4+
param()
5+
"sto͞o′pĭd"
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@{
2+
Path = "Parameters.psd1"
3+
OutputDirectory = "..\Result3"
4+
SemVer = "3.0.0-alpha001"
5+
Target = "Build"
6+
Passthru = $true
7+
}

Tests/Integration/Result3/Parameters/ReadMe.md

Whitespace-only changes.

0 commit comments

Comments
 (0)