This repository was archived by the owner on Feb 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
This repository was archived by the owner on Feb 24, 2021. It is now read-only.
Integration test 'Should return $true when Test-DscConfiguration is run' does not fail #14
Copy link
Copy link
Closed
Labels
bugThe issue is a bug.The issue is a bug.testsThe issue or pull request is about tests only.The issue or pull request is about tests only.
Description
I recently saw that the integration tests 'Should return $true when Test-DscConfiguration is run'
that is part of the integration tests template does not fail as expected.
DscResource.Template/Tests/Integration/integration_test_template.ps1
Lines 108 to 110 in f91a425
It 'Should return $true when Test-DscConfiguration is run' { | |
Test-DscConfiguration -Verbose | Should -Be $true | |
} |
The reason is that Test-DscConfiguration
returns a [System.String]
and not a [System.Boolean]
, so this test always passes regardless of outcome.
Ii can be seen here on this line, it is reported False, but the test passes.
https://ci.appveyor.com/project/johlju/sqlserverdsc/builds/23132521/job/vkxi4xq8jqke7ahf#L1198
Verified it here too
PS > $result = Test-DscConfiguration -Verbose
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = TestConfiguration,'className'
= MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer SQLTEST with user sid S-1-5-21-2246212248-426023572-517575333-1441.
VERBOSE: [SQLTEST]: LCM: [ Start Test ]
VERBOSE: [SQLTEST]: LCM: [ Start Resource ] [[PSModule]InstallModule]
VERBOSE: [SQLTEST]: LCM: [ Start Test ] [[PSModule]InstallModule]
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Determining if the module 'posh-git' is in the
desired state.
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Getting the current state of the module
'posh-git'.
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Begin invoking Get-Module 'posh-git'.
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Populating RepositorySourceLocation property
for module posh-git.
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Loading module from path 'C:\Program
Files\WindowsPowerShell\Modules\posh-git\0.7.3\posh-git.psm1'.
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Module 'posh-git 0.7.3' is found on the node.
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Module 'posh-git' is found on the node.
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Found the module path: 'C:\Program
Files\WindowsPowerShell\Modules\posh-git\0.7.3\PSGetModuleInfo.xml'.
VERBOSE: [SQLTEST]: [[PSModule]InstallModule] Resource 'posh-git' is in the desired state.
VERBOSE: [SQLTEST]: LCM: [ End Test ] [[PSModule]InstallModule] True in 2.6090 seconds.
VERBOSE: [SQLTEST]: LCM: [ End Resource ] [[PSModule]InstallModule]
VERBOSE: [SQLTEST]: LCM: [ End Test ] Completed processing test operation. The operation returned True.
VERBOSE: [SQLTEST]: LCM: [ End Test ] in 3.2500 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 3.348 seconds
PS > $result
True
PS > $result.Gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
So we should either change the line
Test-DscConfiguration -Verbose | Should -Be $true |
to either
$result = Test-DscConfiguration -Verbose
[System.Boolean]::Parse($result) | Should -BeTrue
or
Test-DscConfiguration -Verbose | Should -Be 'True'
Metadata
Metadata
Assignees
Labels
bugThe issue is a bug.The issue is a bug.testsThe issue or pull request is about tests only.The issue or pull request is about tests only.