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
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@
Write-PSFMessage -Level Verbose -Message "Creating Template-Item: $($Item.Name) ($($Item.RelativePath))" -FunctionName Invoke-PSMDTemplate -ModuleName PSModuleDevelopment -Tag 'create', 'template'

$identifier = $Item.Identifier
$isFile = $Item.GetType().Name -eq 'TemplateItemFile'
$isFile = $Item.PSObject.Properties.Name -contains 'Value'

#region File
if ($isFile) {
Expand Down
8 changes: 6 additions & 2 deletions PSModuleDevelopment/tests/functions/Templates.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
Describe "Verifying templating component" {
BeforeAll {
$outPath = (Get-Item -Path 'TestDrive:\').FullName
$outPath = [System.IO.Path]::GetTempPath().Trim("\/")
if ($env:SYSTEM_DEFAULTWORKINGDIRECTORY) { $outPath = $env:SYSTEM_DEFAULTWORKINGDIRECTORY.Trim("\/") }
$resourcePath = Resolve-PSFPath -Path "$PSScriptRoot\..\resources"
$templateName = 'TestTemplate-{0}' -f (Get-Random)
}
AfterAll {
Remove-Item -Path "$outPath\Test.txt" -ErrorAction Ignore
}

It "Should Record the template correctly" {
{ New-PSMDTemplate -TemplateName $templateName -FilePath "$resourcePath\þnameþ.txt" -OutPath $outPath -EnableException -ErrorAction Stop } | Should -Not -Throw
Expand All @@ -27,7 +31,7 @@

It "Should Invoke the template correctly" {
{ Invoke-PSMDTemplate -TemplateName $templateName -Path $outPath -OutPath $outPath -Name Test -EnableException } | Should -Not -Throw
$content = Get-Content -Path "TestDrive:\Test.txt" -ErrorAction Stop
$content = Get-Content -Path "$outPath\Test.txt" -ErrorAction Stop
$values = $content | ConvertFrom-StringData -ErrorAction Stop
$values.Name | Should -Be Test
$values.Value | Should -Be '123'
Expand Down