Skip to content

Commit

Permalink
Correct mocks affected by moving the version correction into Initiali…
Browse files Browse the repository at this point in the history
…zeBuild
  • Loading branch information
Jaykul committed Mar 7, 2024
1 parent 8eddb81 commit 704e1fd
Showing 1 changed file with 39 additions and 15 deletions.
54 changes: 39 additions & 15 deletions Tests/Public/Build-Module.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -257,21 +257,28 @@ Describe "Build-Module" {
New-Item -ItemType Directory -Path TestDrive:/MyModule/ -Force
New-Item -ItemType Directory -Path "TestDrive:/Output/MyModule/$ExpectedVersion" -Force

Mock InitializeBuild {
# These are actually all the values that we need
Mock ResolveBuildManifest { "TestDrive:/MyModule/build.psd1" }

Mock GetBuildInfo {
[PSCustomObject]@{
OutputDirectory = "TestDrive:/Output"
Name = "MyModule"
Version = $Version
SourcePath = "TestDrive:/MyModule/"
SemVer = $SemVer
Target = $Target
ModuleBase = "TestDrive:/MyModule/"
CopyPaths = @()
Encoding = "UTF8"
PublicFilter = "Public/*.ps1"
VersionedOutputDirectory = $true
}
}

Mock ImportModuleManifest {
[PSCustomObject]@{
Name = "MyModule"
ModuleBase = "TestDrive:/MyModule/"
}
}

$global:Mock_OutputPath = Convert-FolderSeparator "TestDrive:/Output/MyModule/$ExpectedVersion"

Mock Get-ChildItem {
Expand Down Expand Up @@ -356,22 +363,31 @@ Describe "Build-Module" {
$global:ExpectedVersion = "1.0.0"
Push-Location TestDrive:/ -StackName BuildModuleTest
New-Item -ItemType Directory -Path TestDrive:/MyModule/ -Force
New-Item -ItemType Directory -Path "TestDrive:/Output/MyModule/$ExpectedVersion" -Force
New-Item -ItemType Directory -Path "TestDrive:/Output/MyModule" -Force

Mock InitializeBuild {
# These are actually all the values that we need
Mock ResolveBuildManifest { "TestDrive:/MyModule/build.psd1" }

Mock GetBuildInfo {
[PSCustomObject]@{
OutputDirectory = "TestDrive:/Output"
Name = "MyModule"
Version = $Version
Target = $Target
ModuleBase = "TestDrive:/MyModule/"
CopyPaths = @()
SourcePath = "TestDrive:/MyModule/"
Version = "1.0.0"
Prerelease = "beta03"
BuildMetadata = "Sha.22c35ffff166f34addc49a3b80e622b543199cc5.Date.2018-10-11"
Target = "CleanBuild"
CopyPaths = @()
Encoding = "UTF8"
PublicFilter = "Public/*.ps1"
}
}

Mock ImportModuleManifest {
[PSCustomObject]@{
Name = "MyModule"
ModuleBase = "TestDrive:/MyModule/"
}
}

$global:Mock_OutputPath = Convert-FolderSeparator "TestDrive:/Output/MyModule"
Mock Get-ChildItem {
[IO.FileInfo]"$TestDrive/MyModule/Public/Get-MyInfo.ps1"
Expand Down Expand Up @@ -510,20 +526,28 @@ Describe "Build-Module" {
New-Item -ItemType Directory -Path TestDrive:/MyModule/ -Force
New-Item -ItemType Directory -Path "TestDrive:/$ExpectedVersion/" -Force

Mock InitializeBuild {
Mock GetBuildInfo {
# These are actually all the values that we need
[PSCustomObject]@{
OutputDirectory = "TestDrive:/$Version"
Name = "MyModule"
Version = $Version
PreRelease = $PreRelease
Target = $Target
ModuleBase = "TestDrive:/MyModule/"
SourcePath = "TestDrive:/MyModule/"
CopyPaths = @()
Encoding = "UTF8"
PublicFilter = "Public/*.ps1"
}
}

Mock ImportModuleManifest {
[PSCustomObject]@{
Name = "MyModule"
ModuleBase = "TestDrive:/MyModule/"
}
}

$global:Mock_OutputPath = Convert-FolderSeparator "TestDrive:/MyModule/$ExpectedVersion"

Mock Get-ChildItem {
Expand Down

0 comments on commit 704e1fd

Please sign in to comment.