Skip to content

Commit 704e1fd

Browse files
committed
Correct mocks affected by moving the version correction into InitializeBuild
1 parent 8eddb81 commit 704e1fd

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

Tests/Public/Build-Module.Tests.ps1

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -257,21 +257,28 @@ Describe "Build-Module" {
257257
New-Item -ItemType Directory -Path TestDrive:/MyModule/ -Force
258258
New-Item -ItemType Directory -Path "TestDrive:/Output/MyModule/$ExpectedVersion" -Force
259259

260-
Mock InitializeBuild {
261-
# These are actually all the values that we need
260+
Mock ResolveBuildManifest { "TestDrive:/MyModule/build.psd1" }
261+
262+
Mock GetBuildInfo {
262263
[PSCustomObject]@{
263264
OutputDirectory = "TestDrive:/Output"
264-
Name = "MyModule"
265-
Version = $Version
265+
SourcePath = "TestDrive:/MyModule/"
266+
SemVer = $SemVer
266267
Target = $Target
267-
ModuleBase = "TestDrive:/MyModule/"
268268
CopyPaths = @()
269269
Encoding = "UTF8"
270270
PublicFilter = "Public/*.ps1"
271271
VersionedOutputDirectory = $true
272272
}
273273
}
274274

275+
Mock ImportModuleManifest {
276+
[PSCustomObject]@{
277+
Name = "MyModule"
278+
ModuleBase = "TestDrive:/MyModule/"
279+
}
280+
}
281+
275282
$global:Mock_OutputPath = Convert-FolderSeparator "TestDrive:/Output/MyModule/$ExpectedVersion"
276283

277284
Mock Get-ChildItem {
@@ -356,22 +363,31 @@ Describe "Build-Module" {
356363
$global:ExpectedVersion = "1.0.0"
357364
Push-Location TestDrive:/ -StackName BuildModuleTest
358365
New-Item -ItemType Directory -Path TestDrive:/MyModule/ -Force
359-
New-Item -ItemType Directory -Path "TestDrive:/Output/MyModule/$ExpectedVersion" -Force
366+
New-Item -ItemType Directory -Path "TestDrive:/Output/MyModule" -Force
360367

361-
Mock InitializeBuild {
362-
# These are actually all the values that we need
368+
Mock ResolveBuildManifest { "TestDrive:/MyModule/build.psd1" }
369+
370+
Mock GetBuildInfo {
363371
[PSCustomObject]@{
364372
OutputDirectory = "TestDrive:/Output"
365-
Name = "MyModule"
366-
Version = $Version
367-
Target = $Target
368-
ModuleBase = "TestDrive:/MyModule/"
369-
CopyPaths = @()
373+
SourcePath = "TestDrive:/MyModule/"
374+
Version = "1.0.0"
375+
Prerelease = "beta03"
376+
BuildMetadata = "Sha.22c35ffff166f34addc49a3b80e622b543199cc5.Date.2018-10-11"
377+
Target = "CleanBuild"
378+
CopyPaths = @()
370379
Encoding = "UTF8"
371380
PublicFilter = "Public/*.ps1"
372381
}
373382
}
374383

384+
Mock ImportModuleManifest {
385+
[PSCustomObject]@{
386+
Name = "MyModule"
387+
ModuleBase = "TestDrive:/MyModule/"
388+
}
389+
}
390+
375391
$global:Mock_OutputPath = Convert-FolderSeparator "TestDrive:/Output/MyModule"
376392
Mock Get-ChildItem {
377393
[IO.FileInfo]"$TestDrive/MyModule/Public/Get-MyInfo.ps1"
@@ -510,20 +526,28 @@ Describe "Build-Module" {
510526
New-Item -ItemType Directory -Path TestDrive:/MyModule/ -Force
511527
New-Item -ItemType Directory -Path "TestDrive:/$ExpectedVersion/" -Force
512528

513-
Mock InitializeBuild {
529+
Mock GetBuildInfo {
514530
# These are actually all the values that we need
515531
[PSCustomObject]@{
516532
OutputDirectory = "TestDrive:/$Version"
517533
Name = "MyModule"
518534
Version = $Version
535+
PreRelease = $PreRelease
519536
Target = $Target
520-
ModuleBase = "TestDrive:/MyModule/"
537+
SourcePath = "TestDrive:/MyModule/"
521538
CopyPaths = @()
522539
Encoding = "UTF8"
523540
PublicFilter = "Public/*.ps1"
524541
}
525542
}
526543

544+
Mock ImportModuleManifest {
545+
[PSCustomObject]@{
546+
Name = "MyModule"
547+
ModuleBase = "TestDrive:/MyModule/"
548+
}
549+
}
550+
527551
$global:Mock_OutputPath = Convert-FolderSeparator "TestDrive:/MyModule/$ExpectedVersion"
528552

529553
Mock Get-ChildItem {

0 commit comments

Comments
 (0)