Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,54 @@
# ModuleForgeCaseTest
Minimal integration-test fixture for ModuleForge. Validates cross-platform module case resolution: the scenario where PSResourceGet installs to a lowercase folder on case-sensitive filesystems, breaking discoverability. Not intended for general use.

Minimal integration-test fixture for the [ModuleForge](https://github.com/adrian-andersson/ModuleForge) project. Not intended for general use.

---

## What This Module Is

ModuleForge includes a function `Resolve-MFModuleCase` that detects and repairs a specific cross-platform failure mode: when PSResourceGet installs a module to a **lowercase folder** on a case-sensitive filesystem (Linux, Mac), the folder name no longer matches the manifest basename, and both `Get-Module` and `Import-Module` fail.

This module exists solely to test that repair path in Pester-testing. Mocking a module install is insufficient for this as the test needs an actual module on PSGallery, installed via PSResourceGet, with a real manifest and a real folder structure on disk.

---

## What problem is this solving exactly ?

NuGet V3 specification explicitely requires all artifacts to be in lower case. PSResourceGet and PowerShell modules both generally expect PascalCase. Since PSResourceGet names the module folder after the NuGet artifact name, that means that if you use PSResourceGet with a V3 NuGet repository (such as Azure-DevOps or GitHub Packages), your module gets installed into a lower-case named folder.

However, on case-sensitive systems, this creates a problem, as `Get-Module`, `Import-Module` can only discover modules where the module manifest name matches exactly (including casing) the module folder name.

The work-around is simple, but still needs actioning: Rename the folder to whatever the basename of the manifest is

---

## What It Contains

A single exported function:

```powershell
Get-MFCaseTestValue
```

Returns a fixed known string. After `Resolve-MFModuleCase` repairs the folder casing, the integration test imports this module and calls this function to confirm the module is not just technically discoverable, but genuinely importable and functional.

---

## Why It Is On PSGallery

The integration test installs this module via `Install-PSResource` as part of its `BeforeAll` setup. PSGallery is the only realistic install source for a cross-platform test that needs to replicate exactly what happens in a real NuGet/PSResourceGet install — including the lowercase folder behaviour on Linux.

The module is kept intentionally minimal and versioned conservatively. It will not change in ways that break the tests that depend on it.

---

## Who Should Use This

Nobody, really, unless you are contributing to or debugging ModuleForge's integration test suite. If you are looking for utilities that do something useful, this is not the module you want.

---

## Related

- [ModuleForge](https://github.com/adrian-andersson/ModuleForge) - the project this module supports
- `Resolve-MFModuleCase` - the function under test
21 changes: 21 additions & 0 deletions source/functions/Get-MFCaseTestValue.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
BeforeAll{
#Load This File
$fileName = $PSCommandPath.Replace('.Tests.ps1','.ps1')
$functionName = 'Get-MFCaseTestValue'
. $fileName
}
Describe 'Check Clean Environment' {
BeforeAll {
write-warning "PSCommandPath: $psCommandPath; scriptToLoad: $($PSCommandPath.Replace('.Tests.ps1','.ps1'))"
}
It 'Should have loaded the script directly, not from the module' {
$PSCommandPath.Replace('.Tests.ps1','.ps1')|should -be $fileName
(get-command $functionName).source |should -BeNullOrEmpty
}
}

Describe 'Get-MFCaseTestValue' {
It 'Should return the expected string' {
Get-MFCaseTestValue | Should -BeExactly '4ce21793-6112-4269-9a7a-f972edbd5327'
}
}
42 changes: 42 additions & 0 deletions source/functions/Get-MFCaseTestValue.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
function Get-MFCaseTestValue
{

<#
.SYNOPSIS
Return a string

.DESCRIPTION
Actually, return this specific string: 4ce21793-6112-4269-9a7a-f972edbd5327

------------
.EXAMPLE
Get-MFCaseTestValue


#### OUTPUT
4ce21793-6112-4269-9a7a-f972edbd532

.NOTES
Author: Adrian Andersson

.OUTPUTS
[STRING] - Returns a specific string of '4ce21793-6112-4269-9a7a-f972edbd532'

#>

[CmdletBinding()]
PARAM(

)
begin{
#Return the script name when running verbose, makes it tidier
write-verbose "===========Executing $($MyInvocation.InvocationName)==========="
#Return the sent variables when running debug
Write-Debug "BoundParams: $($MyInvocation.BoundParameters|Out-String)"
}

process{
return '4ce21793-6112-4269-9a7a-f972edbd5327'
}

}
Loading