Skip to content

Commit c4ad039

Browse files
committed
Remove redundant tests from Install-SqlDscServer unit tests
1 parent 9f5d03b commit c4ad039

File tree

2 files changed

+1
-154
lines changed

2 files changed

+1
-154
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3535
- `Install-SqlDscServer` and private function `Invoke-SetupAction`
3636
- Fix localization string keys naming.
3737
- Fix unit tests to use correct localization string names.
38+
- Remove redundant unit tests.
3839
- `SqlConfiguration`
3940
- Change the alias command to real command name, to pass HQRM tests.
4041
- `SqlDatabaseUser`

tests/Unit/Public/Install-SqlDscServer.Tests.ps1

Lines changed: 0 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -652,102 +652,6 @@ Describe 'Install-SqlDscServer' -Tag 'Public' {
652652
} -Exactly -Times 1 -Scope It
653653
}
654654
}
655-
656-
Context 'When specifying sensitive parameter <MockParameterName>' -ForEach @(
657-
@{
658-
MockParameterName = 'PBEngSvcPassword'
659-
MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line
660-
MockExpectedRegEx = '\/PBENGSVCPASSWORD="\*{8}"' # cspell: disable-line
661-
}
662-
@{
663-
MockParameterName = 'PBDMSSvcPassword' # cspell: disable-line
664-
MockParameterValue = ('jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force) # cspell: disable-line
665-
MockExpectedRegEx = '\/PBDMSSVCPASSWORD="\*{8}"' # cspell: disable-line
666-
}
667-
@{
668-
MockParameterName = 'ProductKey' # cspell: disable-line
669-
MockParameterValue = '22222-00000-00000-00000-00000'
670-
MockExpectedRegEx = '\/PID="\*{8}"' # cspell: disable-line
671-
}
672-
@{
673-
MockParameterName = 'AgtSvcPassword' # cspell: disable-line
674-
MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line
675-
MockExpectedRegEx = '\/AGTSVCPASSWORD="\*{8}"' # cspell: disable-line
676-
}
677-
@{
678-
MockParameterName = 'SAPwd'
679-
MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line
680-
MockExpectedRegEx = '\/SAPWD="\*{8}"' # cspell: disable-line
681-
}
682-
@{
683-
MockParameterName = 'SqlSvcPassword'
684-
MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line
685-
MockExpectedRegEx = '\/SQLSVCPASSWORD="\*{8}"' # cspell: disable-line
686-
}
687-
@{
688-
MockParameterName = 'ISSvcPassword'
689-
MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line
690-
MockExpectedRegEx = '\/ISSVCPASSWORD="\*{8}"' # cspell: disable-line
691-
}
692-
@{
693-
MockParameterName = 'RSSvcPassword'
694-
MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line
695-
MockExpectedRegEx = '\/RSSVCPASSWORD="\*{8}"' # cspell: disable-line
696-
}
697-
@{
698-
MockParameterName = 'AzureServicePrincipalSecret'
699-
MockParameterValue = 'jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force # cspell: disable-line
700-
MockExpectedRegEx = '\/AZURESERVICEPRINCIPALSECRET="\*{8}"' # cspell: disable-line
701-
}
702-
) {
703-
BeforeAll {
704-
Mock -CommandName Write-Verbose
705-
Mock -CommandName Start-SqlSetupProcess -MockWith {
706-
return 0
707-
} -RemoveParameterValidation 'FilePath'
708-
709-
$mockDefaultParameters = @{
710-
Install = $true
711-
AcceptLicensingTerms = $true
712-
MediaPath = '\SqlMedia'
713-
InstanceName = 'INSTANCE'
714-
# Intentionally using both upper- and lower-case in the value.
715-
Features = 'SqlEngine'
716-
SqlSysAdminAccounts = 'DOMAIN\User'
717-
Force = $true
718-
ErrorAction = 'Stop'
719-
}
720-
}
721-
722-
BeforeEach {
723-
$installSqlDscServerParameters = $mockDefaultParameters.Clone()
724-
}
725-
726-
It 'Should obfuscate the value in the verbose string' {
727-
$installSqlDscServerParameters.$MockParameterName = $MockParameterValue
728-
729-
# Redirect all verbose stream to $null to ge no output from ShouldProcess.
730-
Install-SqlDscServer @installSqlDscServerParameters -Verbose 4> $null
731-
732-
$mockVerboseMessage = InModuleScope -ScriptBlock {
733-
$script:localizedData.Invoke_SetupAction_SetupArguments
734-
}
735-
736-
Should -Invoke -CommandName Write-Verbose -ParameterFilter {
737-
# Only test the command that output the string that should be tested.
738-
$correctMessage = $Message -match $mockVerboseMessage
739-
740-
# Only test string if it is the correct verbose command
741-
if ($correctMessage)
742-
{
743-
$Message | Should -MatchExactly $MockExpectedRegEx
744-
}
745-
746-
# Return wether the correct command was called or not.
747-
$correctMessage
748-
} -Exactly -Times 1 -Scope It
749-
}
750-
}
751655
}
752656

753657
Context 'When setup action is ''Upgrade''' {
@@ -2280,64 +2184,6 @@ Describe 'Install-SqlDscServer' -Tag 'Public' {
22802184
} -Exactly -Times 1 -Scope It
22812185
}
22822186
}
2283-
2284-
Context 'When specifying sensitive parameter <MockParameterName>' -ForEach @(
2285-
@{
2286-
MockParameterName = 'FarmPassword'
2287-
MockParameterValue = ('jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force) # cspell: disable-line
2288-
MockExpectedRegEx = '\/FARMPASSWORD="\*{8}"' # cspell: disable-line
2289-
}
2290-
@{
2291-
MockParameterName = 'Passphrase'
2292-
MockParameterValue = ('jT7ELPbD2GGuvLmjABDL' | ConvertTo-SecureString -AsPlainText -Force) # cspell: disable-line
2293-
MockExpectedRegEx = '\/PASSPHRASE="\*{8}"' # cspell: disable-line
2294-
}
2295-
) {
2296-
BeforeAll {
2297-
Mock -CommandName Write-Verbose
2298-
Mock -CommandName Start-SqlSetupProcess -MockWith {
2299-
return 0
2300-
}
2301-
2302-
$mockDefaultParameters = @{
2303-
Install = $true
2304-
AcceptLicensingTerms = $true
2305-
MediaPath = '\SqlMedia'
2306-
Role = 'SPI_AS_NewFarm'
2307-
Force = $true
2308-
ErrorAction = 'Stop'
2309-
}
2310-
}
2311-
2312-
BeforeEach {
2313-
$installSqlDscServerParameters = $mockDefaultParameters.Clone()
2314-
}
2315-
2316-
It 'Should obfuscate the value in the verbose string' {
2317-
$installSqlDscServerParameters.$MockParameterName = $MockParameterValue
2318-
2319-
# Redirect all verbose stream to $null to ge no output from ShouldProcess.
2320-
Install-SqlDscServer @installSqlDscServerParameters -Verbose 4> $null
2321-
2322-
$mockVerboseMessage = InModuleScope -ScriptBlock {
2323-
$script:localizedData.Invoke_SetupAction_SetupArguments
2324-
}
2325-
2326-
Should -Invoke -CommandName Write-Verbose -ParameterFilter {
2327-
# Only test the command that output the string that should be tested.
2328-
$correctMessage = $Message -match $mockVerboseMessage
2329-
2330-
# Only test string if it is the correct verbose command
2331-
if ($correctMessage)
2332-
{
2333-
$Message | Should -MatchExactly $MockExpectedRegEx
2334-
}
2335-
2336-
# Return wether the correct command was called or not.
2337-
$correctMessage
2338-
} -Exactly -Times 1 -Scope It
2339-
}
2340-
}
23412187
}
23422188

23432189
Context 'When role is ''AllFeatures_WithDefaults''' {

0 commit comments

Comments
 (0)