4
4
Describe ' PowerShell adapter resource tests' {
5
5
6
6
BeforeAll {
7
- if ($isWindows ) {
8
- winrm quickconfig - quiet - force
9
- }
10
7
$OldPSModulePath = $env: PSModulePath
11
8
$env: PSModulePath += [System.IO.Path ]::PathSeparator + $PSScriptRoot
12
9
@@ -16,7 +13,6 @@ Describe 'PowerShell adapter resource tests' {
16
13
else
17
14
{
18
15
$cacheFilePath = Join-Path $env: LocalAppData " dsc" " PSAdapterCache.json"
19
- $cacheFilePath_v5 = Join-Path $env: LocalAppData " dsc" " WindowsPSAdapterCache.json"
20
16
}
21
17
}
22
18
AfterAll {
@@ -25,7 +21,6 @@ Describe 'PowerShell adapter resource tests' {
25
21
26
22
BeforeEach {
27
23
Remove-Item - Force - ea SilentlyContinue - Path $cacheFilePath
28
- Remove-Item - Force - ea SilentlyContinue - Path $cacheFilePath_v5
29
24
}
30
25
31
26
It ' Discovery includes class-based and script-based resources ' - Skip:(! $IsWindows ){
@@ -37,34 +32,6 @@ Describe 'PowerShell adapter resource tests' {
37
32
($resources | ? {$_.Type -eq ' PSTestModule/TestPSRepository' }).Count | Should - Be 1
38
33
}
39
34
40
- It ' Windows PowerShell adapter supports File resource' - Skip:(! $IsWindows ){
41
-
42
- $r = dsc resource list -- adapter Microsoft.Windows/ WindowsPowerShell
43
- $LASTEXITCODE | Should - Be 0
44
- $resources = $r | ConvertFrom-Json
45
- ($resources | ? {$_.Type -eq ' PSDesiredStateConfiguration/File' }).Count | Should - Be 1
46
- }
47
-
48
- It ' Get works on Binary "File" resource' - Skip:(! $IsWindows ){
49
-
50
- $testFile = " $testdrive \test.txt"
51
- ' test' | Set-Content - Path $testFile - Force
52
- $r = ' {"DestinationPath":"' + $testFile.replace (' \' , ' \\' ) + ' "}' | dsc resource get - r ' PSDesiredStateConfiguration/File'
53
- $LASTEXITCODE | Should - Be 0
54
- $res = $r | ConvertFrom-Json
55
- $res.actualState.result.properties.DestinationPath | Should - Be " $testFile "
56
- }
57
-
58
- It ' Get works on traditional "Script" resource' - Skip:(! $IsWindows ){
59
-
60
- $testFile = " $testdrive \test.txt"
61
- ' test' | Set-Content - Path $testFile - Force
62
- $r = ' {"GetScript": "@{result = $(Get-Content ' + $testFile.replace (' \' , ' \\' ) + ' )}", "SetScript": "throw", "TestScript": "throw"}' | dsc resource get - r ' PSDesiredStateConfiguration/Script'
63
- $LASTEXITCODE | Should - Be 0
64
- $res = $r | ConvertFrom-Json
65
- $res.actualState.result.properties.result | Should - Be ' test'
66
- }
67
-
68
35
It ' Get works on class-based resource' - Skip:(! $IsWindows ){
69
36
70
37
$r = " {'Name':'TestClassResource1'}" | dsc resource get - r ' TestClassResource/TestClassResource'
@@ -73,14 +40,6 @@ Describe 'PowerShell adapter resource tests' {
73
40
$res.actualState.result.properties.Prop1 | Should - BeExactly ' ValueForProp1'
74
41
}
75
42
76
- It ' Get works on script-based resource' - Skip:(! $IsWindows ){
77
-
78
- $r = " {'Name':'TestPSRepository1'}" | dsc resource get - r ' PSTestModule/TestPSRepository'
79
- $LASTEXITCODE | Should - Be 0
80
- $res = $r | ConvertFrom-Json
81
- $res.actualState.result.properties.PublishLocation | Should - BeExactly ' https://www.powershellgallery.com/api/v2/package/'
82
- }
83
-
84
43
It ' Get uses enum names on class-based resource' - Skip:(! $IsWindows ){
85
44
86
45
$r = " {'Name':'TestClassResource1'}" | dsc resource get - r ' TestClassResource/TestClassResource'
@@ -89,14 +48,6 @@ Describe 'PowerShell adapter resource tests' {
89
48
$res.actualState.result.properties.EnumProp | Should - BeExactly ' Expected'
90
49
}
91
50
92
- It ' Get uses enum names on script-based resource' - Skip:(! $IsWindows ){
93
-
94
- $r = " {'Name':'TestPSRepository1'}" | dsc resource get - r ' PSTestModule/TestPSRepository'
95
- $LASTEXITCODE | Should - Be 0
96
- $res = $r | ConvertFrom-Json
97
- $res.actualState.result.properties.Ensure | Should - BeExactly ' Present'
98
- }
99
-
100
51
It ' Test works on class-based resource' - Skip:(! $IsWindows ){
101
52
102
53
$r = " {'Name':'TestClassResource1','Prop1':'ValueForProp1'}" | dsc resource test - r ' TestClassResource/TestClassResource'
@@ -105,14 +56,6 @@ Describe 'PowerShell adapter resource tests' {
105
56
$res.actualState.result.properties.InDesiredState | Should - Be $True
106
57
}
107
58
108
- It ' Test works on script-based resource' - Skip:(! $IsWindows ){
109
-
110
- $r = " {'Name':'TestPSRepository1','PackageManagementProvider':'NuGet'}" | dsc resource test - r ' PSTestModule/TestPSRepository'
111
- $LASTEXITCODE | Should - Be 0
112
- $res = $r | ConvertFrom-Json
113
- $res.actualState.result.properties.InDesiredState | Should - Be $True
114
- }
115
-
116
59
It ' Set works on class-based resource' - Skip:(! $IsWindows ){
117
60
118
61
$r = " {'Name':'TestClassResource1','Prop1':'ValueForProp1'}" | dsc resource set - r ' TestClassResource/TestClassResource'
@@ -121,14 +64,6 @@ Describe 'PowerShell adapter resource tests' {
121
64
$res.afterState.result | Should -Not - BeNull
122
65
}
123
66
124
- It ' Set works on script-based resource' - Skip:(! $IsWindows ){
125
-
126
- $r = " {'Name':'TestPSRepository1'}" | dsc resource set - r ' PSTestModule/TestPSRepository'
127
- $LASTEXITCODE | Should - Be 0
128
- $res = $r | ConvertFrom-Json
129
- $res.afterState.result.properties.RebootRequired | Should -Not - BeNull
130
- }
131
-
132
67
It ' Export works on PS class-based resource' - Skip:(! $IsWindows ){
133
68
134
69
$r = dsc resource export - r TestClassResource/ TestClassResource
0 commit comments