Skip to content

Commit 4423284

Browse files
authored
Test-SqlDscDatabaseProperty: Validate SQL Server database properties (#2317)
1 parent e3f5e58 commit 4423284

18 files changed

+2573
-38
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ applyTo: "**"
2727
## SQL Server Interaction
2828
- Always prefer SMO over T-SQL
2929
- Unit tests: Use SMO stub types from SMO.cs, never mock SMO types
30-
- Run tests in new session after changing SMO.cs
3130

3231
## Testing CI Environment
3332
- Database Engine: instance `DSCSQLTEST`

.github/instructions/dsc-community-style-guidelines-pester.instructions.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ applyTo: "**/*.[Tt]ests.ps1"
5252
- Public commands: `tests/Unit/Public/{Name}.Tests.ps1`
5353
- Private functions: `tests/Unit/Private/{Name}.Tests.ps1`
5454

55-
## Data-Driven Tests
56-
- Define variables in separate `BeforeDiscovery` for `-ForEach` (close to usage)
55+
## Data-Driven Tests (Test Cases)
56+
- Define `-ForEach` variables in `BeforeDiscovery` (close to usage)
5757
- `-ForEach` allowed on `Context` and `It` blocks
58-
- Keep scope close to usage context
58+
- Never add `param()` inside Pester blocks when using `-ForEach`
59+
- Access test case properties directly: `$PropertyName`
5960

6061
## Best Practices
6162
- Cover all scenarios and code paths

.github/instructions/dsc-community-style-guidelines-powershell.instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ function Get-Something
188188
- Parameter type on line above parameter name
189189
- Parameters separated by blank line
190190
- Parameters should use full type name.
191-
- Pipeline parameters (`ValueFromPipeline = $true`) must be declared in ALL parameter sets
191+
- `ValueFromPipeline` must be consistent across all parameter sets declarations for the same parameter
192192

193193
## Best Practices
194194

.vscode/settings.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,23 @@
9191
"SOURCEBRANCHNAME",
9292
"setvariable",
9393
"RAISERROR",
94-
"filegroup"
94+
"filegroup",
95+
"checkdb",
96+
"msdb",
97+
"db_datawriter",
98+
"db_ddladmin",
99+
"db_owner",
100+
"db_accessadmin",
101+
"db_securityadmin",
102+
"db_backupoperator",
103+
"db_denydatareader",
104+
"db_denydatawriter",
105+
"OLTP",
106+
"LCID",
107+
"varchar",
108+
"maxdop",
109+
"hotfixes",
110+
"checkpointing"
95111
],
96112
"cSpell.ignorePaths": [
97113
".git"

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9393
- Added integration tests for `Test-SqlDscIsDatabasePrincipal` command to ensure
9494
it functions correctly in real environments
9595
[issue #2231](https://github.com/dsccommunity/SqlServerDsc/issues/2231).
96+
- Added public command `Test-SqlDscDatabaseProperty` to test database properties
97+
on SQL Server Database Engine instances. This command supports two parameter sets:
98+
`ServerObject` with **DatabaseName**, and `DatabaseObject` (from `Get-SqlDscDatabase`).
99+
It allows users to specify any non-collection properties of the SMO Database object
100+
as dynamic parameters to test, returning `$true` if all tested properties match
101+
their expected values, and `$false` otherwise. This command improves maintainability
102+
of SQL DSC resources and provides granular database configuration testing
103+
[issue #2306](https://github.com/dsccommunity/SqlServerDsc/issues/2306).
96104

97105
### Fixed
98106

azure-pipelines.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ stages:
337337
'tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1'
338338
'tests/Integration/Commands/Set-SqlDscDatabase.Integration.Tests.ps1'
339339
'tests/Integration/Commands/Test-SqlDscDatabase.Integration.Tests.ps1'
340+
'tests/Integration/Commands/Test-SqlDscDatabaseProperty.Integration.Tests.ps1'
340341
'tests/Integration/Commands/Get-SqlDscDatabasePermission.Integration.Tests.ps1'
341342
'tests/Integration/Commands/Set-SqlDscDatabasePermission.Integration.Tests.ps1'
342343
'tests/Integration/Commands/ConvertTo-SqlDscDatabasePermission.Integration.Tests.ps1'

source/Public/Install-SqlDscBIReportServer.ps1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
Installs SQL Server Power BI Report Server using the provided setup executable.
77
88
.PARAMETER AcceptLicensingTerms
9-
Required parameter to be able to run unattended install. By specifying this
9+
Specifies that the acceptance of all license terms and notices for the
10+
specified features is required to be able to run unattended install. By specifying this
1011
parameter you acknowledge the acceptance of all license terms and notices for
1112
the specified features, the terms and notices that the setup executable
1213
normally asks for.
@@ -20,7 +21,7 @@
2021
This parameter is mutually exclusive with the parameter Edition.
2122
2223
.PARAMETER EditionUpgrade
23-
Upgrades the edition of the installed product. Requires that either the
24+
Specifies whether to upgrade the edition of the installed product. Requires that either the
2425
ProductKey or the Edition parameter is also assigned. By default no edition
2526
upgrade is performed.
2627
@@ -40,7 +41,7 @@
4041
PI Report Server: %ProgramFiles%\Microsoft Power BI Report Server
4142
4243
.PARAMETER SuppressRestart
43-
Suppresses the restart of the computer after the installation is finished.
44+
Specifies whether to suppress the restart of the computer after the installation is finished.
4445
By default the computer is restarted after the installation is finished.
4546
4647
.PARAMETER Timeout
@@ -49,11 +50,11 @@
4950
this time, an exception will be thrown.
5051
5152
.PARAMETER Force
52-
If specified the command will not ask for confirmation. Same as if Confirm:$false
53+
Specifies whether the command will not ask for confirmation. Same as if Confirm:$false
5354
is used.
5455
5556
.PARAMETER PassThru
56-
If specified the command will return the setup process exit code.
57+
Specifies whether the command will return the setup process exit code.
5758
5859
.OUTPUTS
5960
When PassThru is specified the function will return the setup process exit

source/Public/Invoke-SqlDscQuery.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Specifies current server connection object.
1010
1111
.PARAMETER ServerName
12-
Specifies the server name where the instance exist.
12+
Specifies the server name where the instance exists.
1313
1414
.PARAMETER InstanceName
1515
Specifies the instance name on which to execute the T-SQL query.
@@ -29,21 +29,21 @@
2929
Specifies the name of the database to execute the T-SQL query in.
3030
3131
.PARAMETER Query
32-
The query string to execute.
32+
Specifies the query string to execute.
3333
3434
.PARAMETER PassThru
35-
Specifies if the command should return any result the query might return.
35+
Specifies whether the command should return any result the query might return.
3636
3737
.PARAMETER StatementTimeout
38-
Set the query StatementTimeout in seconds. Default 600 seconds (10 minutes).
38+
Specifies the query StatementTimeout in seconds. Default 600 seconds (10 minutes).
3939
4040
.PARAMETER RedactText
41-
One or more text strings to redact from the query when verbose messages
41+
Specifies one or more text strings to redact from the query when verbose messages
4242
are written to the console. Strings will be escaped so they will not
4343
be interpreted as regular expressions (RegEx).
4444
4545
.PARAMETER Encrypt
46-
Specifies if encryption should be used.
46+
Specifies whether encryption should be used.
4747
4848
.PARAMETER Force
4949
Specifies that the query should be executed without any confirmation.

source/Public/New-SqlDscAgentOperator.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
Specifies the weekday pager start time for the SQL Agent Operator.
4646
4747
.PARAMETER PassThru
48-
If specified, the created operator object will be returned.
48+
Specifies whether the created operator object will be returned.
4949
5050
.PARAMETER Force
5151
Specifies that the operator should be created without any confirmation.

source/Public/Set-SqlDscAgentAlert.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
Cannot be used together with Severity.
2525
2626
.PARAMETER PassThru
27-
If specified, the updated alert object will be returned.
27+
Specifies whether the updated alert object will be returned.
2828
2929
.PARAMETER Refresh
3030
Specifies that the alert object should be refreshed before updating. This

0 commit comments

Comments
 (0)