@@ -227,6 +227,65 @@ title: Invoke-NovaBuild
227227 }
228228 }
229229
230+ It ' Get-LocalModulePath returns the first matching local module path for the current platform' {
231+ InModuleScope $script :moduleName {
232+ $originalModulePath = $env: PSModulePath
233+ $script :expectedModulePath = if ($IsWindows ) {
234+ ' C:\Users\Stiwi\Documents\PowerShell\Modules'
235+ }
236+ else {
237+ ' /Users/stiwi.courage/.local/share/powershell/Modules'
238+ }
239+
240+ $env: PSModulePath = if ($IsWindows ) {
241+ ' C:\Program Files\PowerShell\Modules;C:\Users\Stiwi\Documents\PowerShell\Modules;C:\Temp\Modules'
242+ }
243+ else {
244+ ' /usr/local/share/powershell/Modules:/Users/stiwi.courage/.local/share/powershell/Modules:/tmp/modules'
245+ }
246+
247+ Mock Test-Path {
248+ param ($Path )
249+ return $Path -eq $script :expectedModulePath
250+ }
251+
252+ try {
253+ Get-LocalModulePath | Should - Be $script :expectedModulePath
254+ }
255+ finally {
256+ $env: PSModulePath = $originalModulePath
257+ }
258+ }
259+ }
260+
261+ It ' Get-LocalModulePath throws a platform-specific error when no matching path exists' {
262+ InModuleScope $script :moduleName {
263+ $originalModulePath = $env: PSModulePath
264+ $env: PSModulePath = if ($IsWindows ) {
265+ ' C:\Program Files\PowerShell\Modules;C:\Temp\Modules'
266+ }
267+ else {
268+ ' /usr/local/share/powershell/Modules:/tmp/modules'
269+ }
270+
271+ Mock Test-Path {$false }
272+
273+ $expectedError = if ($IsWindows ) {
274+ ' No windows module path matching*'
275+ }
276+ else {
277+ ' No macOS/Linux module path matching*'
278+ }
279+
280+ try {
281+ {Get-LocalModulePath } | Should - Throw $expectedError
282+ }
283+ finally {
284+ $env: PSModulePath = $originalModulePath
285+ }
286+ }
287+ }
288+
230289 It ' built module keeps Publish-NovaModule local path resolution before build and test' {
231290 $packagedModulePath = (Get-Module $script :moduleName ).Path
232291
0 commit comments