Skip to content

Commit 4564df7

Browse files
committed
Fix a few tests that will break if we check module manifests better
1 parent e6a894c commit 4564df7

File tree

4 files changed

+15
-25
lines changed

4 files changed

+15
-25
lines changed

Tests/Private/GetBuildInfo.Tests.ps1

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ Describe "GetBuildInfo" {
1111

1212
Context "It collects the initial data" {
1313

14-
New-Item "TestDrive:\MyModule\Source\build.psd1" -Type File -Force
15-
New-Item "TestDrive:\MyModule\Source\MyModule.psd1" -Type File -Force
14+
# use -Force to create the subdirectories
15+
New-Item -Force "TestDrive:\MyModule\Source\build.psd1" -Type File -Value "@{ Path = 'MyModule.psd1' }"
16+
New-ModuleManifest "TestDrive:\MyModule\Source\MyModule.psd1" -Author Tester
1617

1718
$Result = InModuleScope -ModuleName ModuleBuilder {
1819

@@ -68,18 +69,12 @@ Describe "GetBuildInfo" {
6869
}} | Should -Throw
6970
}
7071

71-
It 'Should throw if the Module manifest does not exists' {
72+
It 'Should throw if the Module manifest does not exist' {
73+
# use -Force to create the subdirectories
7274
New-Item -Force TestDrive:\NoModuleManifest\Source\build.psd1 -ItemType File
7375
{InModuleScope -ModuleName ModuleBuilder {
7476
GetBuildInfo -BuildManifest TestDrive:\NoModuleManifest\Source\build.psd1
7577
}} | Should -Throw
7678
}
7779
}
78-
79-
Context "Invalid module manifest" {
80-
# In the current PowerShell 5.1 and 6.1
81-
# I can't make Get-Module -ListAvailable throw on a manifest
82-
# So I can't test the if($Problems = ... code
83-
}
84-
8580
}

Tests/Private/InitializeBuild.Tests.ps1

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,16 @@ Describe "InitializeBuild" {
44

55
Context "It collects the initial data" {
66

7-
New-Item "TestDrive:\Source\build.psd1" -Type File -Force
8-
New-Item "TestDrive:\Source\MyModule.psd1" -Type File -Force
9-
10-
Set-Content "TestDrive:\Source\MyModule.psd1" '@{
11-
RootModule = "MyModule.psm1"
12-
Author = "Test Manager"
13-
Version = "1.0.0"
14-
}'
15-
167
# Note that "Path" is an alias for "SourcePath"
17-
Set-Content "TestDrive:\build.psd1" '@{
8+
New-Item "TestDrive:\build.psd1" -Type File -Force -Value '@{
189
Path = ".\Source\MyModule.psd1"
1910
SourceDirectories = @("Classes", "Private", "Public")
2011
}'
2112

13+
New-Item "TestDrive:\Source\" -Type Directory
14+
15+
New-ModuleManifest "TestDrive:\Source\MyModule.psd1" -RootModule "MyModule.psm1" -Author "Test Manager" -ModuleVersion "1.0.0"
16+
2217
$Result = @{}
2318

2419
It "Handles Build-Module parameters, and the build.psd1 configuration" {
@@ -35,7 +30,7 @@ Describe "InitializeBuild" {
3530
)
3631
try {
3732
Write-Warning $($MyInvocation.MyCommand | Out-String)
38-
InitializeBuild -SourcePath $SourcePath -Debug
33+
InitializeBuild -SourcePath $SourcePath
3934
} catch {
4035
$_
4136
}
@@ -51,8 +46,8 @@ Describe "InitializeBuild" {
5146

5247
It "Returns the ModuleInfo combined with the BuildInfo" {
5348
$Result.Name | Should -Be "MyModule"
54-
$result.ModuleType | Should -Be "Manifest"
55-
(Convert-FolderSeparator $Result.ModuleBase) | Should -Be (Convert-FolderSeparator "TestDrive:\Source")
49+
$Result.SourceDirectories | Should -Be @("Classes", "Private", "Public")
50+
(Convert-FolderSeparator $Result.ModuleBase) | Should -Be (Convert-FolderSeparator "TestDrive:\Source")
5651
(Convert-FolderSeparator $Result.SourcePath) | Should -Be (Convert-FolderSeparator "TestDrive:\Source\MyModule.psd1")
5752
}
5853

Tests/Public/Build-Module.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ Describe "Build-Module" {
531531
Context "Does not fall over if you build from the drive root" {
532532

533533
$null = New-Item "TestDrive:\build.psd1" -Type File -Force -Value "@{}"
534-
$null = New-Item "TestDrive:\MyModule.psd1" -Type File -Force -value '@{ModuleVersion="1.0.0";Author="TEST"}'
534+
$null = New-ModuleManifest "TestDrive:\MyModule.psd1" -ModuleVersion "1.0.0" -Author "Tester"
535535
$null = New-Item "TestDrive:\Public\Test.ps1" -Type File -Value 'MATCHING TEST CONTENT' -Force
536536

537537
Mock GetBuildInfo -ModuleName ModuleBuilder {

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ resources:
1010
endpoint: PoshCode
1111
type: github
1212
name: PoshCode/Azure-Pipelines
13-
ref: refs/tags/3.2.0
13+
ref: refs/tags/3.2.1
1414

1515
stages:
1616
- stage: Build

0 commit comments

Comments
 (0)