Skip to content

Commit 0c9a63e

Browse files
authored
Merge branch 'main' into copilot/fix-2237
2 parents 1019cb2 + c25588e commit 0c9a63e

File tree

249 files changed

+1956
-274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

249 files changed

+1956
-274
lines changed

.github/instructions/SqlServerDsc-guidelines.instructions.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ applyTo: "**"
66
# SqlServerDsc Requirements
77

88
## Build & Test Workflow Requirements
9-
- Run PowerShell script files from repository root
9+
- Never use VS Code task, always use PowerShell scripts via terminal, from repository root
1010
- Setup build and test environment (once per `pwsh` session): `./build.ps1 -Tasks noop`
1111
- Build project before running tests: `./build.ps1 -Tasks build`
1212
- Run tests without coverage (wildcards allowed): `Invoke-PesterJob -Path '{tests filepath}' -SkipCodeCoverage`
13+
- Run tests with coverage (wildcards allowed): `Invoke-PesterJob -Path '{tests filepath}' -EnableSourceLineMapping -FilterCodeCoverageResult '{pattern}'`
1314
- Run QA tests: `Invoke-PesterJob -Path 'tests/QA' -SkipCodeCoverage`
1415
- Never run integration tests locally
1516

CHANGELOG.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,54 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
### Added
99

10+
- Added integration tests for `Get-SqlDscManagedComputer` command to ensure it
11+
functions correctly in real environments
12+
[issue #2220](https://github.com/dsccommunity/SqlServerDsc/issues/2220).
1013
- Added integration tests for `Remove-SqlDscAudit` command to ensure it functions
1114
correctly in real environments
1215
[issue #2241](https://github.com/dsccommunity/SqlServerDsc/issues/2241).
1316
- Added integration tests for `Save-SqlDscSqlServerMediaFile` command to ensure
1417
it functions correctly in real environments
1518
[issue #2237](https://github.com/dsccommunity/SqlServerDsc/issues/2237).
19+
- Added integration test for `ConvertTo-SqlDscEditionName` command to ensure
20+
command reliability in real environments
21+
[issue #2208](https://github.com/dsccommunity/SqlServerDsc/issues/2208).
22+
- Added integration tests for `Import-SqlDscPreferredModule` command to ensure
23+
proper module import functionality in real environments
24+
[issue #2225](https://github.com/dsccommunity/SqlServerDsc/issues/2225).
25+
- Added integration tests for `Test-SqlDscIsSupportedFeature` command to ensure
26+
it functions correctly in real environments
27+
[issue #2228](https://github.com/dsccommunity/SqlServerDsc/issues/2228).
28+
- Added integration test for `Get-SqlDscManagedComputerService` command to ensure
29+
command reliability [issue #2219](https://github.com/dsccommunity/SqlServerDsc/issues/2219).
30+
- Added integration tests for `Set-SqlDscTraceFlag` command to ensure it functions
31+
correctly in real environments
32+
[issue #2232](https://github.com/dsccommunity/SqlServerDsc/issues/2232).
33+
- Added integration tests for `ConvertFrom-SqlDscServerPermission` command to
34+
ensure it functions correctly in real environments
35+
[issue #2210](https://github.com/dsccommunity/SqlServerDsc/issues/2210).
36+
- `Remove-SqlDscTraceFlag`
37+
- Added missing integration test to ensure command reliability ([issue #2239](https://github.com/dsccommunity/SqlServerDsc/issues/2239)).
38+
- `Remove-SqlDscAudit`
39+
- Added missing integration test to ensure command reliability ([issue #2241](https://github.com/dsccommunity/SqlServerDsc/issues/2241)).
40+
- Added integration tests for `Test-SqlDscIsRole` command to ensure it functions
41+
correctly in real environments
42+
[issue #2229](https://github.com/dsccommunity/SqlServerDsc/issues/2229).
43+
- Added integration tests for `Add-SqlDscTraceFlag` command to ensure it functions
44+
correctly in real environments
45+
[issue #2214](https://github.com/dsccommunity/SqlServerDsc/issues/2214).
1646

1747
### Fixed
1848

49+
- `Add-SqlDscTraceFlag` and `Remove-SqlDscTraceFlag`
50+
- Fixed parameter binding error when `ErrorAction` was specified both
51+
explicitly and via `PSBoundParameters` by using `Remove-CommonParameter`
52+
instead of manual parameter removal
53+
([issue #2239](https://github.com/dsccommunity/SqlServerDsc/issues/2239)).
54+
- `Remove-SqlDscTraceFlag`
55+
- Optimized to skip unnecessary Set operations when removal results in no
56+
effective change
57+
([issue #2239](https://github.com/dsccommunity/SqlServerDsc/issues/2239)).
1958
- Updated `.gitattributes` to enforce LF line endings for PowerShell files to
2059
ensure cross-platform compatibility.
2160
- Updated GitHub Copilot setup workflow to fix environment variable assignment

azure-pipelines.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ stages:
287287
# Group 0
288288
'tests/Integration/Commands/Prerequisites.Integration.Tests.ps1'
289289
'tests/Integration/Commands/Save-SqlDscSqlServerMediaFile.Integration.Tests.ps1'
290+
'tests/Integration/Commands/Import-SqlDscPreferredModule.Integration.Tests.ps1'
290291
# Group 1
291292
'tests/Integration/Commands/Install-SqlDscServer.Integration.Tests.ps1'
292293
'tests/Integration/Commands/Connect-SqlDscDatabaseEngine.Integration.Tests.ps1'
@@ -297,16 +298,23 @@ stages:
297298
'tests/Integration/Commands/Get-SqlDscConfigurationOption.Integration.Tests.ps1'
298299
'tests/Integration/Commands/Set-SqlDscConfigurationOption.Integration.Tests.ps1'
299300
'tests/Integration/Commands/Test-SqlDscConfigurationOption.Integration.Tests.ps1'
301+
'tests/Integration/Commands/Test-SqlDscIsSupportedFeature.Integration.Tests.ps1'
302+
'tests/Integration/Commands/Get-SqlDscManagedComputer.Integration.Tests.ps1'
303+
'tests/Integration/Commands/Set-SqlDscTraceFlag.Integration.Tests.ps1'
300304
'tests/Integration/Commands/Get-SqlDscManagedComputerInstance.Integration.Tests.ps1'
305+
'tests/Integration/Commands/Get-SqlDscManagedComputerService.Integration.Tests.ps1'
301306
'tests/Integration/Commands/Get-SqlDscServerProtocolName.Integration.Tests.ps1'
307+
'tests/Integration/Commands/ConvertTo-SqlDscEditionName.Integration.Tests.ps1'
302308
'tests/Integration/Commands/Get-SqlDscServerProtocol.Integration.Tests.ps1'
303309
'tests/Integration/Commands/Disable-SqlDscLogin.Integration.Tests.ps1'
304310
'tests/Integration/Commands/Enable-SqlDscLogin.Integration.Tests.ps1'
305311
'tests/Integration/Commands/Test-SqlDscIsLoginEnabled.Integration.Tests.ps1'
306312
'tests/Integration/Commands/New-SqlDscRole.Integration.Tests.ps1'
307313
'tests/Integration/Commands/Get-SqlDscRole.Integration.Tests.ps1'
314+
'tests/Integration/Commands/Test-SqlDscIsRole.Integration.Tests.ps1'
308315
'tests/Integration/Commands/Grant-SqlDscServerPermission.Integration.Tests.ps1'
309316
'tests/Integration/Commands/Get-SqlDscServerPermission.Integration.Tests.ps1'
317+
'tests/Integration/Commands/ConvertFrom-SqlDscServerPermission.Integration.Tests.ps1'
310318
'tests/Integration/Commands/Test-SqlDscServerPermission.Integration.Tests.ps1'
311319
'tests/Integration/Commands/Deny-SqlDscServerPermission.Integration.Tests.ps1'
312320
'tests/Integration/Commands/Revoke-SqlDscServerPermission.Integration.Tests.ps1'
@@ -326,13 +334,15 @@ stages:
326334
'tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1'
327335
'tests/Integration/Commands/Enable-SqlDscAgentOperator.Integration.Tests.ps1'
328336
'tests/Integration/Commands/Disable-SqlDscAgentOperator.Integration.Tests.ps1'
337+
'tests/Integration/Commands/Add-SqlDscTraceFlag.Integration.Tests.ps1'
329338
# Group 8
330339
'tests/Integration/Commands/Remove-SqlDscAgentAlert.Integration.Tests.ps1'
331340
'tests/Integration/Commands/Remove-SqlDscAgentOperator.Integration.Tests.ps1'
332341
'tests/Integration/Commands/Remove-SqlDscAudit.Integration.Tests.ps1'
333342
'tests/Integration/Commands/Remove-SqlDscDatabase.Integration.Tests.ps1'
334343
'tests/Integration/Commands/Remove-SqlDscRole.Integration.Tests.ps1'
335344
'tests/Integration/Commands/Remove-SqlDscLogin.Integration.Tests.ps1'
345+
'tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1'
336346
# Group 9
337347
'tests/Integration/Commands/Uninstall-SqlDscServer.Integration.Tests.ps1'
338348
)
@@ -398,6 +408,7 @@ stages:
398408
# Group 0
399409
'tests/Integration/Commands/Prerequisites.Integration.Tests.ps1'
400410
'tests/Integration/Commands/Save-SqlDscSqlServerMediaFile.Integration.Tests.ps1'
411+
'tests/Integration/Commands/Import-SqlDscPreferredModule.Integration.Tests.ps1'
401412
# Group 1
402413
'tests/Integration/Commands/Install-SqlDscReportingService.Integration.Tests.ps1'
403414
# Group 2
@@ -462,6 +473,7 @@ stages:
462473
# Group 0
463474
'tests/Integration/Commands/Prerequisites.Integration.Tests.ps1'
464475
'tests/Integration/Commands/Save-SqlDscSqlServerMediaFile.Integration.Tests.ps1'
476+
'tests/Integration/Commands/Import-SqlDscPreferredModule.Integration.Tests.ps1'
465477
# Group 1
466478
'tests/Integration/Commands/Install-SqlDscBIReportServer.Integration.Tests.ps1'
467479
# Group 2

source/Public/Add-SqlDscTraceFlag.ps1

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,10 @@ function Add-SqlDscTraceFlag
9696
}
9797

9898
# Copy $PSBoundParameters to keep it intact.
99-
$getSqlDscTraceFlagParameters = @{} + $PSBoundParameters
99+
$getSqlDscTraceFlagParameters = Remove-CommonParameter -Hashtable $PSBoundParameters
100100

101-
$commonParameters = [System.Management.Automation.PSCmdlet]::OptionalCommonParameters
102-
103-
# Remove parameters that Get-SqlDscTraceFLag does not have/support.
104-
$commonParameters + @('Force', 'TraceFlag') |
101+
# Remove parameters that Get-SqlDscTraceFlag does not have/support.
102+
@('Force', 'TraceFlag') |
105103
ForEach-Object -Process {
106104
$getSqlDscTraceFlagParameters.Remove($_)
107105
}
@@ -132,9 +130,9 @@ function Add-SqlDscTraceFlag
132130
if ($PSCmdlet.ShouldProcess($verboseDescriptionMessage, $verboseWarningMessage, $captionMessage))
133131
{
134132
# Copy $PSBoundParameters to keep it intact.
135-
$setSqlDscTraceFlagParameters = @{} + $PSBoundParameters
133+
$setSqlDscTraceFlagParameters = Remove-CommonParameter -Hashtable $PSBoundParameters
136134

137-
$setSqlDscTraceFlagParameters.TraceFLag = $desiredTraceFlags
135+
$setSqlDscTraceFlagParameters.TraceFlag = $desiredTraceFlags
138136

139137
$originalErrorActionPreference = $ErrorActionPreference
140138

source/Public/Remove-SqlDscTraceFlag.ps1

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,10 @@ function Remove-SqlDscTraceFlag
9696
}
9797

9898
# Copy $PSBoundParameters to keep it intact.
99-
$getSqlDscTraceFlagParameters = @{} + $PSBoundParameters
99+
$getSqlDscTraceFlagParameters = Remove-CommonParameter -Hashtable $PSBoundParameters
100100

101-
$commonParameters = [System.Management.Automation.PSCmdlet]::OptionalCommonParameters
102-
103-
# Remove parameters that Get-SqlDscTraceFLag does not have/support.
104-
$commonParameters + @('Force', 'TraceFlag') |
101+
# Remove parameters that Get-SqlDscTraceFlag does not have/support.
102+
@('Force', 'TraceFlag') |
105103
ForEach-Object -Process {
106104
$getSqlDscTraceFlagParameters.Remove($_)
107105
}
@@ -128,16 +126,23 @@ function Remove-SqlDscTraceFlag
128126
}
129127
)
130128

129+
# Short-circuit if removal results in no effective change
130+
if (-not (Compare-Object -ReferenceObject $currentTraceFlags -DifferenceObject $desiredTraceFlags))
131+
{
132+
Write-Debug -Message $script:localizedData.TraceFlag_Remove_NoChange
133+
return
134+
}
135+
131136
$verboseDescriptionMessage = $script:localizedData.TraceFlag_Remove_ShouldProcessVerboseDescription -f $InstanceName, ($TraceFlag -join ', ')
132137
$verboseWarningMessage = $script:localizedData.TraceFlag_Remove_ShouldProcessVerboseWarning -f $InstanceName
133138
$captionMessage = $script:localizedData.TraceFlag_Remove_ShouldProcessCaption
134139

135140
if ($PSCmdlet.ShouldProcess($verboseDescriptionMessage, $verboseWarningMessage, $captionMessage))
136141
{
137142
# Copy $PSBoundParameters to keep it intact.
138-
$setSqlDscTraceFlagParameters = @{} + $PSBoundParameters
143+
$setSqlDscTraceFlagParameters = Remove-CommonParameter -Hashtable $PSBoundParameters
139144

140-
$setSqlDscTraceFlagParameters.TraceFLag = $desiredTraceFlags
145+
$setSqlDscTraceFlagParameters.TraceFlag = $desiredTraceFlags
141146

142147
$originalErrorActionPreference = $ErrorActionPreference
143148

source/en-US/SqlServerDsc.strings.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ ConvertFrom-StringData @'
216216
# This string shall not end with full stop (.) since it is used as a title of ShouldProcess messages.
217217
TraceFlag_Remove_ShouldProcessCaption = Remove trace flag from instance
218218
TraceFlag_Remove_NoCurrentTraceFlags = There are no current trace flags on instance. Nothing to remove.
219+
TraceFlag_Remove_NoChange = The specified trace flags are not currently set on the instance. No changes needed.
219220
220221
## Get-SqlDscPreferredModule
221222
PreferredModule_ModuleVersionFound = Preferred module '{0}' with version '{1}' found.

0 commit comments

Comments
 (0)