Skip to content

Commit

Permalink
Feedback 1
Browse files Browse the repository at this point in the history
  • Loading branch information
anmenaga committed Nov 21, 2023
1 parent 6f3e789 commit 667b916
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
10 changes: 5 additions & 5 deletions wmigroup/Tests/test_wmi_config.dsc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ resources:
properties:
resources:
- name: Get OS Info
type: root\cimv2/Win32_OperatingSystem
- name: Get OS Info
type: root\cimv2/Win32_BIOS
- name: Get OS Info
type: root\cimv2/Win32_Processor
type: root.cimv2/Win32_OperatingSystem
- name: Get BIOS Info
type: root.cimv2/Win32_BIOS
- name: Get Processor Info
type: root.cimv2/Win32_Processor
25 changes: 19 additions & 6 deletions wmigroup/Tests/wmigroup.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,26 @@
Describe 'PowerShellGroup resource tests' {

BeforeAll {
$OldPSModulePath = $env:PSModulePath
$env:PSModulePath += ";" + $PSScriptRoot

$configPath = Join-path $PSScriptRoot "test_wmi_config.dsc.yaml"
if ($IsWindows)
{
$OldPSModulePath = $env:PSModulePath
$env:PSModulePath += ";" + $PSScriptRoot

$configPath = Join-path $PSScriptRoot "test_wmi_config.dsc.yaml"

$dscPath = (get-command dsc -CommandType Application).Path
$dscFolder = Split-Path -Path $dscPath
$wmiGroupOptoutFile = Join-Path $dscFolder "wmigroup.dsc.resource.json.optout"
$wmiGroupOptinFile = Join-Path $dscFolder "wmigroup.dsc.resource.json"
Rename-Item -Path $wmiGroupOptoutFile -NewName $wmiGroupOptinFile
}
}
AfterAll {
$env:PSModulePath = $OldPSModulePath
if ($IsWindows)
{
$env:PSModulePath = $OldPSModulePath
Rename-Item -Path $wmiGroupOptinFile -NewName $wmiGroupOptoutFile
}
}

It 'List shows WMI resources' -Skip:(!$IsWindows){
Expand All @@ -23,7 +36,7 @@ Describe 'PowerShellGroup resource tests' {

It 'Get works on an individual WMI resource' -Skip:(!$IsWindows){

$r = dsc resource get -r root\cimv2/Win32_OperatingSystem
$r = dsc resource get -r root.cimv2/Win32_OperatingSystem
$LASTEXITCODE | Should -Be 0
$res = $r | ConvertFrom-Json
$res.actualState.CreationClassName | Should -Be "Win32_OperatingSystem"
Expand Down
1 change: 1 addition & 0 deletions wmigroup/copy_files.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
wmigroup.resource.ps1
wmigroup.dsc.resource.json.optout
File renamed without changes.
6 changes: 3 additions & 3 deletions wmigroup/wmigroup.resource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if ($Operation -eq 'List')
}
}

$namespace = $r.CimSystemProperties.Namespace.ToLower().Replace('/','\')
$namespace = $r.CimSystemProperties.Namespace.ToLower().Replace('/','.')
$classname = $r.CimSystemProperties.ClassName
$fullResourceTypeName = "$namespace/$classname"
$requiresString = "DSC/WMIGroup"
Expand Down Expand Up @@ -66,7 +66,7 @@ elseif ($Operation -eq 'Get')
foreach($r in $inputobj_pscustomobj.resources)
{
$type_fields = $r.type -split "/"
$wmi_namespace = $type_fields[0]
$wmi_namespace = $type_fields[0].Replace('.','\')
$wmi_classname = $type_fields[1]

#TODO: add filtering based on supplied properties of $r
Expand Down Expand Up @@ -96,7 +96,7 @@ elseif ($Operation -eq 'Get')
else # we are processing an individual resource call
{
$type_fields = $inputobj_pscustomobj.type -split "/"
$wmi_namespace = $type_fields[0]
$wmi_namespace = $type_fields[0].Replace('.','\')
$wmi_classname = $type_fields[1]

#TODO: add filtering based on supplied properties of $inputobj_pscustomobj
Expand Down

0 comments on commit 667b916

Please sign in to comment.