Skip to content

Commit f4d6915

Browse files
Merge pull request #210 from PowershellFrameworkCollective/typeconversion-fix
changing temp path
2 parents aa5a65a + 8de6c17 commit f4d6915

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

PSModuleDevelopment/functions/templating/Invoke-PSMDTemplate.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@
337337
Write-PSFMessage -Level Verbose -Message "Creating Template-Item: $($Item.Name) ($($Item.RelativePath))" -FunctionName Invoke-PSMDTemplate -ModuleName PSModuleDevelopment -Tag 'create', 'template'
338338

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

342342
#region File
343343
if ($isFile) {

PSModuleDevelopment/tests/functions/Templates.Tests.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
Describe "Verifying templating component" {
22
BeforeAll {
3-
$outPath = (Get-Item -Path 'TestDrive:\').FullName
3+
$outPath = [System.IO.Path]::GetTempPath().Trim("\/")
4+
if ($env:SYSTEM_DEFAULTWORKINGDIRECTORY) { $outPath = $env:SYSTEM_DEFAULTWORKINGDIRECTORY.Trim("\/") }
45
$resourcePath = Resolve-PSFPath -Path "$PSScriptRoot\..\resources"
56
$templateName = 'TestTemplate-{0}' -f (Get-Random)
67
}
8+
AfterAll {
9+
Remove-Item -Path "$outPath\Test.txt" -ErrorAction Ignore
10+
}
711

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

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

0 commit comments

Comments
 (0)