tests/Invoke-GenerateModuleFile.Tests.ps1
# . ( Resolve-Path "$PSScriptRoot\..\src\Private\Invoke-GenerateModuleFile.ps1" ) # $requiredModules = @( 'Carbon', 'posh-git' ) # $expected = @" # `$requiredModules = @( 'Carbon', 'posh-git' ) # `$notFound = @() # foreach (`$moduleName in `$requiredModules) { # `$module = Get-Module -ListAvailable -Name `$moduleName # if (`$null -eq `$module) { # `$notFound += `$moduleName # } # } # if (`$notFound.Count -gt 0) { # throw "Following modules cannot be found on machine: `$notFound. Install missing modules using command 'Install-Module'" # } # `$script:ModuleName = Split-Path -Path `$PSScriptRoot -Leaf # `$Public = @( Get-ChildItem -Path `$PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue ) # `$Private = @( Get-ChildItem -Path `$PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue ) # foreach ( `$FunctionFilePath in @( `$Public + `$Private ) ) { # try { # . `$FunctionFilePath.FullName # } catch { # Write-Error -Message "Failed to import function '$(`$FunctionFilePath.FullName)': `$_" # } # } # Export-ModuleMember -Function `$Public.Basename # "@ # Describe "Invoke-GenerateModuleFile tests" { # $tempPath = "$PSScriptRoot\tmp" + [System.Guid]::NewGuid() # $moduleFilePath = "$tempPath\SampleModule.psm1" # BeforeEach { # mkdir $tempPath # } # AfterEach { # # Remove-Item -Path $tempPath -Recurse -Force # } # It "Bla bla" { # Invoke-GenerateModuleFile -OutputPath $moduleFilePath -RequiredModules $requiredModules -TemplateOption 0 # $written = Get-Content $moduleFilePath | Out-String # $written = $written.Trim() # $written | Should -BeExactly $expected # } # } |