File tree Expand file tree Collapse file tree 5 files changed +39
-9
lines changed Expand file tree Collapse file tree 5 files changed +39
-9
lines changed Original file line number Diff line number Diff line change 11# Copyright (c) Microsoft Corporation.
22# Licensed under the MIT License.
33
4+ BeforeDiscovery {
5+ try {
6+ $windowWidth = [Console ]::WindowWidth
7+ } catch {
8+ $consoleUnavailable = $true
9+ }
10+ }
11+
412Describe ' Discover extension tests' {
513 BeforeAll {
614 $oldPath = $env: PATH
@@ -110,12 +118,12 @@ Describe 'Discover extension tests' {
110118 }
111119 }
112120
113- It ' Table can be not truncated' {
121+ It ' Table can be not truncated' - Skip:( $consoleUnavailable ) {
114122 $output = dsc extension list -- output- format table- no- truncate
115123 $LASTEXITCODE | Should - Be 0
116124 $foundWideLine = $false
117125 foreach ($line in $output ) {
118- if ($line.Length -gt [ Console ]::WindowWidth ) {
126+ if ($line.Length -gt $windowWidth ) {
119127 $foundWideLine = $true
120128 }
121129 }
Original file line number Diff line number Diff line change 11# Copyright (c) Microsoft Corporation.
22# Licensed under the MIT License.
33
4+ BeforeDiscovery {
5+ try {
6+ $windowWidth = [Console ]::WindowWidth
7+ } catch {
8+ $consoleUnavailable = $true
9+ }
10+ }
11+
412Describe ' Tests for listing resources' {
513 It ' dsc resource list' {
614 $resources = dsc resource list | ConvertFrom-Json - Depth 10
@@ -89,12 +97,12 @@ Describe 'Tests for listing resources' {
8997 $out | Should - BeLike " *ERROR*Adapter not found: foo`*"
9098 }
9199
92- It ' Table is not truncated' {
100+ It ' Table is not truncated' - Skip:( $consoleUnavailable ) {
93101 $output = dsc resource list -- output- format table- no- truncate
94102 $LASTEXITCODE | Should - Be 0
95103 $foundWideLine = $false
96104 foreach ($line in $output ) {
97- if ($line.Length -gt [ Console ]::WindowWidth ) {
105+ if ($line.Length -gt $windowWidth ) {
98106 $foundWideLine = $true
99107 break
100108 }
Original file line number Diff line number Diff line change 11# Copyright (c) Microsoft Corporation.
22# Licensed under the MIT License.
33
4- Describe ' Tests for Appx resource discovery' - Skip:(! $IsWindows ){
4+ BeforeDiscovery {
5+ $runningInCI = $null -ne $env: GITHUB_RUN_ID
6+ }
7+
8+ Describe ' Tests for Appx resource discovery' - Skip:(! $IsWindows -or $runningInCI ) {
59 It ' Should find DSC appx resources' {
610 $out = dsc resource list | ConvertFrom-Json
711 $LASTEXITCODE | Should - Be 0
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ Describe 'Bicep extension tests' -Skip:(!$foundBicep) {
1515 $out = dsc - l trace config get -f $bicepFile 2> $TestDrive / error.log | ConvertFrom-Json
1616 $LASTEXITCODE | Should - Be 0 - Because (Get-Content - Path $TestDrive / error.log - Raw | Out-String )
1717 $out.results [0 ].result.actualState.output | Should - BeExactly ' Hello, world!'
18+ $bicepFile = $bicepFile.ToString ().Replace(' \' , ' \\' )
1819 (Get-Content - Path $TestDrive / error.log - Raw) | Should -Match " Importing file '$bicepFile ' with extension 'Microsoft.DSC.Extension/Bicep'"
1920 }
2021
@@ -28,9 +29,10 @@ resource invalid 'Microsoft.DSC.Extension/Bicep:1.0' = {
2829 properties: {
2930 output: 'This is invalid'
3031"@
31- $out = dsc - l trace config get -f $bicepFile 2> $TestDrive / error.log | ConvertFrom-Json
32+ dsc - l trace config get -f $bicepFile 2> $TestDrive / error.log | ConvertFrom-Json
3233 $LASTEXITCODE | Should - Be 4 - Because (Get-Content - Path $TestDrive / error.log - Raw | Out-String )
3334 $content = (Get-Content - Path $TestDrive / error.log - Raw)
35+ $bicepFile = $bicepFile.ToString ().Replace(' \' , ' \\' )
3436 $content | Should -Match " Importing file '$bicepFile ' with extension 'Microsoft.DSC.Extension/Bicep'"
3537 $content | Should -Match " BCP033"
3638 }
Original file line number Diff line number Diff line change 11# Copyright (c) Microsoft Corporation.
22# Licensed under the MIT License.
33
4+ BeforeDiscovery {
5+ if ($IsWindows ) {
6+ $identity = [System.Security.Principal.WindowsIdentity ]::GetCurrent()
7+ $principal = [System.Security.Principal.WindowsPrincipal ]::new($identity )
8+ $isElevated = $principal.IsInRole ([System.Security.Principal.WindowsBuiltInRole ]::Administrator)
9+ }
10+ }
11+
412Describe ' reboot_pending resource tests' {
513 It ' should get reboot_pending' - Skip:(! $IsWindows ) {
614 $out = dsc resource get - r Microsoft.Windows/ RebootPending | ConvertFrom-Json
@@ -15,17 +23,17 @@ Describe 'reboot_pending resource tests' {
1523 $out.results.result.actualState.rebootPending | Should -Not - BeNullOrEmpty
1624 }
1725
18- It ' reboot_pending should have a reason' - Skip:(! $IsWindows ) {
26+ It ' reboot_pending should have a reason' - Skip:(! $IsWindows -or ! $isElevated ) {
1927 $keyPath = " HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update"
2028 $keyName = " RebootRequired"
2129 try {
2230 if (-not (Get-ItemProperty " $keyPath \$keyName " - ErrorAction SilentlyContinue)) {
2331 New-ItemProperty - Path $keyPath - Name $keyName - Value 1 - PropertyType DWord - Force | Out-Null
2432 }
2533
26- $out | dsc resource get - r Microsoft.Windows/ RebootPending | ConvertFrom-Json
34+ $out = dsc resource get - r Microsoft.Windows/ RebootPending | ConvertFrom-Json
2735 $LASTEXITCODE | Should - Be 0
28- $out.actualState.reason.count | Should - BeGreaterThan 0
36+ $out.actualState.reason.count | Should - BeGreaterThan 0 - Because ( $out | Out-String )
2937 } finally {
3038 Remove-ItemProperty - Path $keyPath - Name $keyName - ErrorAction Ignore
3139 }
You can’t perform that action at this time.
0 commit comments