Skip to content

Commit faf65fa

Browse files
authored
Bugfixing (#53)
* ConvertFrom-MappingFile: Error when using powershell-yaml latest version Fixes #52 * fix datetime format in Tests.ps1 having 'hh:...' Fixes #50
1 parent d3fe0d4 commit faf65fa

4 files changed

Lines changed: 11 additions & 13 deletions

File tree

src/Public/ConvertFrom-MappingFile.ps1

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ function ConvertFrom-MappingFile {
3737
process {
3838
$Content = Get-Content -Path $Path -Raw
3939
if ($Path.EndsWith('.yaml')) {
40-
$rawMapping = ConvertFrom-Yaml -Yaml $Content -Ordered -ErrorAction Stop |
41-
ConvertTo-Yaml -JsonCompatible |
42-
ConvertFrom-Json -AsHashtable
40+
$rawMapping = ConvertFrom-Yaml -Yaml $Content -Ordered -ErrorAction Stop
4341
} elseif ($Path.EndsWith('.json')) {
4442
$rawMapping = $Content | ConvertFrom-Json
4543
} else {

tests/Integration/New-IdoitMappedObject.Tests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Describe 'Integration New-IdoitMappedObject' -Tag 'Integration' -Skip:$isNotConn
4141
}
4242
Context 'PERSON' {
4343
It 'Creates a new mapped PERSON object' {
44-
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd hh:mm:ss') $(New-Guid)"
44+
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $(New-Guid)"
4545
$object = [PSCustomObject]@{
4646
FirstName = 'John'
4747
LastName = $nameTestObject
@@ -69,7 +69,7 @@ Describe 'Integration New-IdoitMappedObject' -Tag 'Integration' -Skip:$isNotConn
6969
$obj.ObjId | Should -Be $objId
7070
}
7171
It 'Should allow duplicates when AllowDuplicates is set' {
72-
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd hh:mm:ss') $(New-Guid)"
72+
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $(New-Guid)"
7373
$object = [PSCustomObject]@{
7474
FirstName = 'Jane'
7575
LastName = $nameTestObject
@@ -104,7 +104,7 @@ Describe 'Integration New-IdoitMappedObject' -Tag 'Integration' -Skip:$isNotConn
104104
Register-IdoitCategoryMap -Path (Join-Path -Path $testHelpersPath -ChildPath 'SampleMapping.yaml') -Force
105105
}
106106
It 'Creates a new mapped SERVER object' {
107-
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd hh:mm:ss') $(New-Guid)"
107+
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $(New-Guid)"
108108
$object = [PSCustomObject]@{
109109
ComputerName = $nameTestObject
110110
BeschreibungUndefined = 'This is a test server'
@@ -139,7 +139,7 @@ Describe 'Integration New-IdoitMappedObject' -Tag 'Integration' -Skip:$isNotConn
139139
It 'Creates a new mapped CUSTOM object' {
140140
$VerbosePreference = 'Continue'
141141
$mappingName = 'CustomObjectMapped'
142-
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd hh:mm:ss') $(New-Guid)"
142+
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $(New-Guid)"
143143
$testObject = [PSCustomObject]@{
144144
ComponentType = 'Job / Schnittstelle'
145145
}

tests/Integration/New-IdoitObject.Tests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ Describe 'Integration New-IdoitObject' -Tag 'Integration' -Skip:$isNotConnected
3838
& (Join-Path $testIntegrationHelpersPath Remove-PesterLeftOvers.ps1)
3939
}
4040
It 'Creates a server object without categories' {
41-
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd hh:mm:ss') $(New-Guid)"
41+
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $(New-Guid)"
4242
$ret = New-IdoitObject -Name $nameTestObject -ObjectType "C__OBJTYPE__SERVER"
4343
$ret | Should -Not -BeNullOrEmpty
4444
$ret.ObjId | Should -BeGreaterThan 0
4545
$ret.success | Should -BeTrue
4646
}
4747
It 'Creates a server object including categories' {
48-
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd hh:mm:ss') $(New-Guid)"
48+
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $(New-Guid)"
4949
$categories = @{
5050
'C__CATG__GLOBAL' = [PSCustomObject]@{ title = $nameTestObject }
5151
'C__CATG__OPERATING_SYSTEM' = @([PSCustomObject]@{description = "Windows Server 2022"})
@@ -55,7 +55,7 @@ Describe 'Integration New-IdoitObject' -Tag 'Integration' -Skip:$isNotConnected
5555
}
5656
Context 'Error cases' {
5757
It 'Error when creating a server object with the same name' {
58-
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd hh:mm:ss') $(New-Guid)"
58+
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $(New-Guid)"
5959
$categories = @{
6060
'C__CATG__GLOBAL' = [PSCustomObject]@{ title = $nameTestObject }
6161
'C__CATG__OPERATING_SYSTEM' = @([PSCustomObject]@{description = "Windows Server 2022"})
@@ -65,7 +65,7 @@ Describe 'Integration New-IdoitObject' -Tag 'Integration' -Skip:$isNotConnected
6565
{ New-IdoitObject -Name $nameTestObject -ObjectType "C__OBJTYPE__SERVER" -Category $categories -ErrorAction Stop } | Should -Throw "An object with the name '$nameTestObject' already exists*"
6666
}
6767
It 'Creates a server object but issues a error for category INVALID_CATEGORY' {
68-
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd hh:mm:ss') $(New-Guid)"
68+
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $(New-Guid)"
6969
$categories = @{
7070
'C__CATG__GLOBAL' = [PSCustomObject]@{ title = $nameTestObject }
7171
'INVALID_CATEGORY' = @([PSCustomObject]@{description = "Invalid Category"})

tests/Integration/Set-IdoitMappedObject.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Describe 'Integration Set-IdoitMappedObject' -Tag 'Integration' -Skip:$isNotConn
4242
Context 'PERSON' {
4343
It 'Updates a mapped PERSON object by setting cmdb_status directly via mappped property CMDBStatus' {
4444
# create the test object first
45-
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd hh:mm:ss') $(New-Guid)"
45+
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $(New-Guid)"
4646
$object = [PSCustomObject]@{
4747
FirstName = 'John'
4848
LastName = $nameTestObject
@@ -76,7 +76,7 @@ Describe 'Integration Set-IdoitMappedObject' -Tag 'Integration' -Skip:$isNotConn
7676
It 'Updates a mapped PERSON object by setting cmdb_status indirectly via mapped property cmdb_status.title' {
7777
# this is different to usual setting of a single property value. Reason: It is a dialog field, which requires the id od title assigned to it for update.
7878
# create the test object first
79-
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd hh:mm:ss') $(New-Guid)"
79+
$nameTestObject = "Pester $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $(New-Guid)"
8080
$createdObject = [PSCustomObject]@{
8181
FirstName = 'John'
8282
LastName = $nameTestObject

0 commit comments

Comments
 (0)