Skip to content

Commit 42e6d66

Browse files
authored
Merge branch 'main' into copilot/fix-2222
2 parents 16ca44e + 65a1f9a commit 42e6d66

File tree

259 files changed

+4478
-273
lines changed

Some content is hidden

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

259 files changed

+4478
-273
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: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,84 @@ 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 `Get-SqlDscAudit` command to ensure it functions
1417
correctly in real environments
1518
[issue #2222](https://github.com/dsccommunity/SqlServerDsc/issues/2222).
19+
- Added integration tests for `Invoke-SqlDscQuery` command to ensure it functions
20+
correctly in real environments
21+
[issue #2227](https://github.com/dsccommunity/SqlServerDsc/issues/2227).
22+
- Added integration tests for `New-SqlDscAudit` command to ensure it functions
23+
correctly in real environments
24+
[issue #2226](https://github.com/dsccommunity/SqlServerDsc/issues/2226).
25+
- Added integration tests for `Test-SqlDscIsLogin` command to ensure it functions
26+
correctly in real environments
27+
[issue #2230](https://github.com/dsccommunity/SqlServerDsc/issues/2230).
28+
- Added integration tests for `Set-SqlDscAudit` command to ensure it functions
29+
correctly in real environments
30+
[issue #2236](https://github.com/dsccommunity/SqlServerDsc/issues/2236).
31+
- Added integration tests for `Set-SqlDscStartupParameter` command to ensure
32+
reliable startup parameter configuration
33+
[issue #2233](https://github.com/dsccommunity/SqlServerDsc/issues/2233).
34+
- Added integration tests for `Set-SqlDscServerPermission` command to ensure it
35+
functions correctly in real environments
36+
[issue #2234](https://github.com/dsccommunity/SqlServerDsc/issues/2234).
37+
- Added integration tests for `Save-SqlDscSqlServerMediaFile` command to ensure
38+
it functions correctly in real environments
39+
[issue #2237](https://github.com/dsccommunity/SqlServerDsc/issues/2237).
40+
- Added integration tests for `Disable-SqlDscAudit` command to ensure it functions
41+
correctly in real environments
42+
[issue #2206](https://github.com/dsccommunity/SqlServerDsc/issues/2206).
43+
- Added integration tests for `ConvertTo-SqlDscDatabasePermission` command to
44+
ensure command reliability
45+
[issue #2209](https://github.com/dsccommunity/SqlServerDsc/issues/2209).
46+
- Added integration tests for `Set-SqlDscDatabasePermission` command to ensure
47+
command reliability
48+
[issue #2235](https://github.com/dsccommunity/SqlServerDsc/issues/2235).
49+
- Added integration test for `ConvertTo-SqlDscEditionName` command to ensure
50+
command reliability in real environments
51+
[issue #2208](https://github.com/dsccommunity/SqlServerDsc/issues/2208).
52+
- Added integration tests for `Import-SqlDscPreferredModule` command to ensure
53+
proper module import functionality in real environments
54+
[issue #2225](https://github.com/dsccommunity/SqlServerDsc/issues/2225).
55+
- Added integration tests for `Test-SqlDscIsSupportedFeature` command to ensure
56+
it functions correctly in real environments
57+
[issue #2228](https://github.com/dsccommunity/SqlServerDsc/issues/2228).
58+
- Added integration test for `Get-SqlDscManagedComputerService` command to ensure
59+
command reliability [issue #2219](https://github.com/dsccommunity/SqlServerDsc/issues/2219).
60+
- Added integration tests for `Set-SqlDscTraceFlag` command to ensure it functions
61+
correctly in real environments
62+
[issue #2232](https://github.com/dsccommunity/SqlServerDsc/issues/2232).
63+
- Added integration tests for `ConvertFrom-SqlDscServerPermission` command to
64+
ensure it functions correctly in real environments
65+
[issue #2210](https://github.com/dsccommunity/SqlServerDsc/issues/2210).
66+
- `Remove-SqlDscTraceFlag`
67+
- Added missing integration test to ensure command reliability ([issue #2239](https://github.com/dsccommunity/SqlServerDsc/issues/2239)).
68+
- `Remove-SqlDscAudit`
69+
- Added missing integration test to ensure command reliability ([issue #2241](https://github.com/dsccommunity/SqlServerDsc/issues/2241)).
70+
- Added integration tests for `Test-SqlDscIsRole` command to ensure it functions
71+
correctly in real environments
72+
[issue #2229](https://github.com/dsccommunity/SqlServerDsc/issues/2229).
73+
- Added integration tests for `Add-SqlDscTraceFlag` command to ensure it functions
74+
correctly in real environments
75+
[issue #2214](https://github.com/dsccommunity/SqlServerDsc/issues/2214).
1676

1777
### Fixed
1878

79+
- `Add-SqlDscTraceFlag` and `Remove-SqlDscTraceFlag`
80+
- Fixed parameter binding error when `ErrorAction` was specified both
81+
explicitly and via `PSBoundParameters` by using `Remove-CommonParameter`
82+
instead of manual parameter removal
83+
([issue #2239](https://github.com/dsccommunity/SqlServerDsc/issues/2239)).
84+
- `Remove-SqlDscTraceFlag`
85+
- Optimized to skip unnecessary Set operations when removal results in no
86+
effective change
87+
([issue #2239](https://github.com/dsccommunity/SqlServerDsc/issues/2239)).
1988
- Updated `.gitattributes` to enforce LF line endings for PowerShell files to
2089
ensure cross-platform compatibility.
2190
- Updated GitHub Copilot setup workflow to fix environment variable assignment

azure-pipelines.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ stages:
286286
# Run the integration tests in a specific group order.
287287
# Group 0
288288
'tests/Integration/Commands/Prerequisites.Integration.Tests.ps1'
289+
'tests/Integration/Commands/Save-SqlDscSqlServerMediaFile.Integration.Tests.ps1'
290+
'tests/Integration/Commands/Import-SqlDscPreferredModule.Integration.Tests.ps1'
289291
# Group 1
290292
'tests/Integration/Commands/Install-SqlDscServer.Integration.Tests.ps1'
291293
'tests/Integration/Commands/Connect-SqlDscDatabaseEngine.Integration.Tests.ps1'
@@ -296,25 +298,39 @@ stages:
296298
'tests/Integration/Commands/Get-SqlDscConfigurationOption.Integration.Tests.ps1'
297299
'tests/Integration/Commands/Set-SqlDscConfigurationOption.Integration.Tests.ps1'
298300
'tests/Integration/Commands/Test-SqlDscConfigurationOption.Integration.Tests.ps1'
301+
'tests/Integration/Commands/Set-SqlDscStartupParameter.Integration.Tests.ps1'
302+
'tests/Integration/Commands/Test-SqlDscIsSupportedFeature.Integration.Tests.ps1'
303+
'tests/Integration/Commands/Get-SqlDscManagedComputer.Integration.Tests.ps1'
304+
'tests/Integration/Commands/Set-SqlDscTraceFlag.Integration.Tests.ps1'
299305
'tests/Integration/Commands/Get-SqlDscManagedComputerInstance.Integration.Tests.ps1'
306+
'tests/Integration/Commands/Get-SqlDscManagedComputerService.Integration.Tests.ps1'
300307
'tests/Integration/Commands/Get-SqlDscServerProtocolName.Integration.Tests.ps1'
308+
'tests/Integration/Commands/ConvertTo-SqlDscEditionName.Integration.Tests.ps1'
301309
'tests/Integration/Commands/Get-SqlDscServerProtocol.Integration.Tests.ps1'
302310
'tests/Integration/Commands/Disable-SqlDscLogin.Integration.Tests.ps1'
303311
'tests/Integration/Commands/Enable-SqlDscLogin.Integration.Tests.ps1'
312+
'tests/Integration/Commands/Test-SqlDscIsLogin.Integration.Tests.ps1'
304313
'tests/Integration/Commands/Test-SqlDscIsLoginEnabled.Integration.Tests.ps1'
305314
'tests/Integration/Commands/New-SqlDscRole.Integration.Tests.ps1'
306315
'tests/Integration/Commands/Get-SqlDscRole.Integration.Tests.ps1'
316+
'tests/Integration/Commands/Test-SqlDscIsRole.Integration.Tests.ps1'
307317
'tests/Integration/Commands/Grant-SqlDscServerPermission.Integration.Tests.ps1'
308318
'tests/Integration/Commands/Get-SqlDscServerPermission.Integration.Tests.ps1'
319+
'tests/Integration/Commands/Set-SqlDscServerPermission.Integration.Tests.ps1'
320+
'tests/Integration/Commands/ConvertFrom-SqlDscServerPermission.Integration.Tests.ps1'
309321
'tests/Integration/Commands/Test-SqlDscServerPermission.Integration.Tests.ps1'
310322
'tests/Integration/Commands/Deny-SqlDscServerPermission.Integration.Tests.ps1'
311323
'tests/Integration/Commands/Revoke-SqlDscServerPermission.Integration.Tests.ps1'
312324
'tests/Integration/Commands/Get-SqlDscDatabase.Integration.Tests.ps1'
313325
'tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1'
314326
'tests/Integration/Commands/Set-SqlDscDatabase.Integration.Tests.ps1'
315327
'tests/Integration/Commands/Test-SqlDscDatabase.Integration.Tests.ps1'
328+
'tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1'
329+
'tests/Integration/Commands/Set-SqlDscDatabasePermission.Integration.Tests.ps1'
330+
'tests/Integration/Commands/ConvertTo-SqlDscDatabasePermission.Integration.Tests.ps1'
316331
'tests/Integration/Commands/Get-SqlDscAgentAlert.Integration.Tests.ps1'
317332
'tests/Integration/Commands/New-SqlDscAgentAlert.Integration.Tests.ps1'
333+
'tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1'
318334
'tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1'
319335
'tests/Integration/Commands/Test-SqlDscAgentAlertProperty.Integration.Tests.ps1'
320336
'tests/Integration/Commands/Test-SqlDscIsAgentAlert.Integration.Tests.ps1'
@@ -325,14 +341,18 @@ stages:
325341
'tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1'
326342
'tests/Integration/Commands/Enable-SqlDscAgentOperator.Integration.Tests.ps1'
327343
'tests/Integration/Commands/Disable-SqlDscAgentOperator.Integration.Tests.ps1'
344+
'tests/Integration/Commands/Disable-SqlDscAudit.Integration.Tests.ps1'
345+
'tests/Integration/Commands/Add-SqlDscTraceFlag.Integration.Tests.ps1'
328346
# Group 8
329347
'tests/Integration/Commands/Remove-SqlDscAgentAlert.Integration.Tests.ps1'
330348
'tests/Integration/Commands/Remove-SqlDscAgentOperator.Integration.Tests.ps1'
331349
'tests/Integration/Commands/Get-SqlDscAudit.Integration.Tests.ps1'
332350
'tests/Integration/Commands/Remove-SqlDscAudit.Integration.Tests.ps1'
351+
'tests/Integration/Commands/Set-SqlDscAudit.Integration.Tests.ps1'
333352
'tests/Integration/Commands/Remove-SqlDscDatabase.Integration.Tests.ps1'
334353
'tests/Integration/Commands/Remove-SqlDscRole.Integration.Tests.ps1'
335354
'tests/Integration/Commands/Remove-SqlDscLogin.Integration.Tests.ps1'
355+
'tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1'
336356
# Group 9
337357
'tests/Integration/Commands/Uninstall-SqlDscServer.Integration.Tests.ps1'
338358
)
@@ -397,6 +417,8 @@ stages:
397417
# Run the integration tests in a specific group order.
398418
# Group 0
399419
'tests/Integration/Commands/Prerequisites.Integration.Tests.ps1'
420+
'tests/Integration/Commands/Save-SqlDscSqlServerMediaFile.Integration.Tests.ps1'
421+
'tests/Integration/Commands/Import-SqlDscPreferredModule.Integration.Tests.ps1'
400422
# Group 1
401423
'tests/Integration/Commands/Install-SqlDscReportingService.Integration.Tests.ps1'
402424
# Group 2
@@ -460,6 +482,8 @@ stages:
460482
# Run the integration tests in a specific group order.
461483
# Group 0
462484
'tests/Integration/Commands/Prerequisites.Integration.Tests.ps1'
485+
'tests/Integration/Commands/Save-SqlDscSqlServerMediaFile.Integration.Tests.ps1'
486+
'tests/Integration/Commands/Import-SqlDscPreferredModule.Integration.Tests.ps1'
463487
# Group 1
464488
'tests/Integration/Commands/Install-SqlDscBIReportServer.Integration.Tests.ps1'
465489
# 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)