Skip to content

Commit 72da0cb

Browse files
Copilotjohlju
andcommitted
Address additional code review feedback
Co-authored-by: johlju <[email protected]>
1 parent 18bd1b8 commit 72da0cb

File tree

5 files changed

+28
-11
lines changed

5 files changed

+28
-11
lines changed

source/Public/Get-SqlDscDateTime.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function Get-SqlDscDateTime
8383
process
8484
{
8585
Write-Verbose -Message (
86-
$script:localizedData.DateTime_Get_RetrievingDateTime -f $DateTimeFunction
86+
$script:localizedData.Get_SqlDscDateTime_RetrievingDateTime -f $DateTimeFunction
8787
)
8888

8989
$query = "SELECT $DateTimeFunction()"
@@ -111,7 +111,7 @@ function Get-SqlDscDateTime
111111
catch
112112
{
113113
$writeErrorParameters = @{
114-
Message = $script:localizedData.DateTime_Get_FailedToRetrieve -f $DateTimeFunction, $_.Exception.Message
114+
Message = $script:localizedData.Get_SqlDscDateTime_FailedToRetrieve -f $DateTimeFunction, $_.Exception.Message
115115
Category = 'InvalidOperation'
116116
ErrorId = 'GSDD0001' # cSpell: disable-line
117117
TargetObject = $DateTimeFunction

source/Public/Invoke-SqlDscScalarQuery.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function Invoke-SqlDscScalarQuery
9090
}
9191

9292
Write-Verbose -Message (
93-
$script:localizedData.ScalarQuery_Invoke_ExecutingQuery -f $redactedQuery
93+
$script:localizedData.Invoke_SqlDscScalarQuery_ExecutingQuery -f $redactedQuery
9494
)
9595

9696
$previousStatementTimeout = $null
@@ -112,10 +112,10 @@ function Invoke-SqlDscScalarQuery
112112
catch
113113
{
114114
$writeErrorParameters = @{
115-
Message = $script:localizedData.ScalarQuery_Invoke_FailedToExecute -f $_.Exception.Message
115+
Message = $script:localizedData.Invoke_SqlDscScalarQuery_FailedToExecute -f $_.Exception.Message
116116
Category = 'InvalidOperation'
117117
ErrorId = 'ISDSQ0002' # cSpell: disable-line
118-
TargetObject = $Query
118+
TargetObject = $redactedQuery
119119
Exception = $_.Exception
120120
}
121121

source/en-US/SqlServerDsc.strings.psd1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,10 +634,10 @@ ConvertFrom-StringData @'
634634
Get_SqlDscSetupLog_PathNotFound = Path '{0}' does not exist. (GSDSL0006)
635635
636636
## Invoke-SqlDscScalarQuery
637-
ScalarQuery_Invoke_ExecutingQuery = Executing the scalar query `{0}`. (ISDSQ0001)
638-
ScalarQuery_Invoke_FailedToExecute = Failed to execute scalar query: {0} (ISDSQ0002)
637+
Invoke_SqlDscScalarQuery_ExecutingQuery = Executing the scalar query `{0}`. (ISDSQ0001)
638+
Invoke_SqlDscScalarQuery_FailedToExecute = Failed to execute scalar query: {0} (ISDSQ0002)
639639
640640
## Get-SqlDscDateTime
641-
DateTime_Get_RetrievingDateTime = Retrieving date and time using {0}(). (GSDD0001)
642-
DateTime_Get_FailedToRetrieve = Failed to retrieve date and time using {0}(): {1} (GSDD0002)
641+
Get_SqlDscDateTime_RetrievingDateTime = Retrieving date and time using {0}(). (GSDD0001)
642+
Get_SqlDscDateTime_FailedToRetrieve = Failed to retrieve date and time using {0}(): {1} (GSDD0002)
643643
'@

tests/Integration/Commands/Invoke-SqlDscScalarQuery.Integration.Tests.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ BeforeAll {
3131
Import-Module -Name $script:moduleName -Force -ErrorAction 'Stop'
3232
}
3333

34+
AfterAll {
35+
Remove-Item -Path 'env:SqlServerDscCI' -ErrorAction 'SilentlyContinue'
36+
}
37+
3438
Describe 'Invoke-SqlDscScalarQuery' -Tag @('Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') {
3539
BeforeAll {
3640
$script:mockInstanceName = 'DSCSQLTEST'
@@ -46,8 +50,6 @@ Describe 'Invoke-SqlDscScalarQuery' -Tag @('Integration_SQL2017', 'Integration_S
4650

4751
AfterAll {
4852
Disconnect-SqlDscDatabaseEngine -ServerObject $script:serverObject -Force
49-
50-
Remove-Item -Path 'env:SqlServerDscCI'
5153
}
5254

5355
Context 'When executing a scalar query' {

tests/Unit/Public/Invoke-SqlDscScalarQuery.Tests.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,21 @@ Describe 'Invoke-SqlDscScalarQuery' -Tag 'Public' {
7676
$result.ParameterListAsString | Should -Be $MockExpectedParameters
7777
}
7878

79+
It 'Should have ServerObject as a mandatory parameter' {
80+
$parameterInfo = (Get-Command -Name 'Invoke-SqlDscScalarQuery').Parameters['ServerObject']
81+
$parameterInfo.Attributes.Mandatory | Should -Contain $true
82+
}
83+
84+
It 'Should have Query as a mandatory parameter' {
85+
$parameterInfo = (Get-Command -Name 'Invoke-SqlDscScalarQuery').Parameters['Query']
86+
$parameterInfo.Attributes.Mandatory | Should -Contain $true
87+
}
88+
89+
It 'Should accept ServerObject from pipeline' {
90+
$parameterInfo = (Get-Command -Name 'Invoke-SqlDscScalarQuery').Parameters['ServerObject']
91+
$parameterInfo.Attributes.ValueFromPipeline | Should -Contain $true
92+
}
93+
7994
Context 'When executing a scalar query' {
8095
BeforeAll {
8196
$mockConnectionContext = New-Object -TypeName 'Microsoft.SqlServer.Management.Smo.ServerConnection'

0 commit comments

Comments
 (0)