Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
eb22a3f
`Test-SqlDscDatabaseProperty`: Validate SQL Server database properties
johlju Oct 24, 2025
6ca972b
Update Data-Driven Tests guidelines for Pester usage
johlju Oct 25, 2025
1a815f1
Update `Test-SqlDscDatabaseProperty` command documentation to emphasi…
johlju Oct 25, 2025
c049fc0
Add unique identifiers to database property test messages
johlju Oct 25, 2025
d66b832
Remove redundant mocked class loading before module import in `Before…
johlju Oct 25, 2025
fbd6e81
Add INPUTS section to documentation for Test-SqlDscDatabaseProperty f…
johlju Oct 25, 2025
43759de
Clarify requirement for `ValueFromPipeline` consistency across parame…
johlju Oct 25, 2025
5e132e7
Remove instruction to run tests in a new session after changing SMO.cs
johlju Oct 25, 2025
7f58287
Refactor parameter validation tests for Test-SqlDscDatabaseProperty t…
johlju Oct 25, 2025
52cc453
Add Test-SqlDscDatabaseProperty integration tests to pipeline
johlju Oct 25, 2025
c77a141
Clarify context name for database property parameters in tests
johlju Oct 25, 2025
ab5a2dd
Refactor parameter descriptions in Test-SqlDscDatabaseProperty for cl…
johlju Oct 25, 2025
c824f88
Refactor parameter descriptions across multiple scripts for clarity a…
johlju Oct 25, 2025
e908b5f
Fix typo in example usage of Test-SqlDscDatabaseProperty function
johlju Oct 25, 2025
3453f21
Fix formatting in Force parameter description for consistency
johlju Oct 25, 2025
151cab2
Fix typo in ServerName parameter description for grammatical accuracy
johlju Oct 25, 2025
95488cf
Enhance error handling in Test-SqlDscDatabaseProperty function by spe…
johlju Oct 25, 2025
3f0e056
Add error handling for non-existent database properties in Test-SqlDs…
johlju Oct 25, 2025
7c90d3c
Refactor DatabaseEngineEdition references to use the correct namespac…
johlju Oct 25, 2025
8e0fce3
Refactor DatabaseEngineType references to use the correct namespace i…
johlju Oct 25, 2025
f4f7062
Update test for non-existent database to expect an error instead of a…
johlju Oct 25, 2025
a19c020
Refactor Test-SqlDscDatabaseProperty tests to include expected Boolea…
johlju Oct 25, 2025
9014c4e
Remove unnecessary parameter declaration for DatabaseName in Test-Sql…
johlju Oct 25, 2025
966c7a3
Refactor Test-SqlDscDatabaseProperty tests to improve expected value …
johlju Oct 25, 2025
b1ec970
Enhance value comparison logic in Test-SqlDscDatabaseProperty to hand…
johlju Oct 25, 2025
f697c15
Refactor Test-SqlDscDatabaseProperty integration tests to use Boolean…
johlju Oct 25, 2025
121c286
Refactor value comparison logic in Test-SqlDscDatabaseProperty to imp…
johlju Oct 26, 2025
26e2a31
Add error category and ID to Write-Error in Test-SqlDscDatabaseProper…
johlju Oct 26, 2025
b4eb490
Add integration tests for persistent database creation in New-SqlDscD…
johlju Oct 26, 2025
9afd3cc
Refactor integration tests in Test-SqlDscDatabaseProperty to use pers…
johlju Oct 26, 2025
db9a757
Comment out database properties in Test-SqlDscDatabaseProperty due to…
johlju Oct 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ applyTo: "**"
## SQL Server Interaction
- Always prefer SMO over T-SQL
- Unit tests: Use SMO stub types from SMO.cs, never mock SMO types
- Run tests in new session after changing SMO.cs

## Testing CI Environment
- Database Engine: instance `DSCSQLTEST`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ applyTo: "**/*.[Tt]ests.ps1"
- Public commands: `tests/Unit/Public/{Name}.Tests.ps1`
- Private functions: `tests/Unit/Private/{Name}.Tests.ps1`

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

## Best Practices
- Cover all scenarios and code paths
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ function Get-Something
- Parameter type on line above parameter name
- Parameters separated by blank line
- Parameters should use full type name.
- Pipeline parameters (`ValueFromPipeline = $true`) must be declared in ALL parameter sets
- `ValueFromPipeline` must be consistent across all parameter sets declarations for the same parameter

## Best Practices

Expand Down
18 changes: 17 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,23 @@
"SOURCEBRANCHNAME",
"setvariable",
"RAISERROR",
"filegroup"
"filegroup",
"checkdb",
"msdb",
"db_datawriter",
"db_ddladmin",
"db_owner",
"db_accessadmin",
"db_securityadmin",
"db_backupoperator",
"db_denydatareader",
"db_denydatawriter",
"OLTP",
"LCID",
"varchar",
"maxdop",
"hotfixes",
"checkpointing"
],
"cSpell.ignorePaths": [
".git"
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added integration tests for `Test-SqlDscIsDatabasePrincipal` command to ensure
it functions correctly in real environments
[issue #2231](https://github.com/dsccommunity/SqlServerDsc/issues/2231).
- Added public command `Test-SqlDscDatabaseProperty` to test database properties
on SQL Server Database Engine instances. This command supports two parameter sets:
`ServerObject` with **DatabaseName**, and `DatabaseObject` (from `Get-SqlDscDatabase`).
It allows users to specify any non-collection properties of the SMO Database object
as dynamic parameters to test, returning `$true` if all tested properties match
their expected values, and `$false` otherwise. This command improves maintainability
of SQL DSC resources and provides granular database configuration testing
[issue #2306](https://github.com/dsccommunity/SqlServerDsc/issues/2306).

### Fixed

Expand Down
1 change: 1 addition & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ stages:
'tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1'
'tests/Integration/Commands/Set-SqlDscDatabase.Integration.Tests.ps1'
'tests/Integration/Commands/Test-SqlDscDatabase.Integration.Tests.ps1'
'tests/Integration/Commands/Test-SqlDscDatabaseProperty.Integration.Tests.ps1'
'tests/Integration/Commands/Get-SqlDscDatabasePermission.Integration.Tests.ps1'
'tests/Integration/Commands/Set-SqlDscDatabasePermission.Integration.Tests.ps1'
'tests/Integration/Commands/ConvertTo-SqlDscDatabasePermission.Integration.Tests.ps1'
Expand Down
11 changes: 6 additions & 5 deletions source/Public/Install-SqlDscBIReportServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
Installs SQL Server Power BI Report Server using the provided setup executable.

.PARAMETER AcceptLicensingTerms
Required parameter to be able to run unattended install. By specifying this
Specifies that the acceptance of all license terms and notices for the
specified features is required to be able to run unattended install. By specifying this
parameter you acknowledge the acceptance of all license terms and notices for
the specified features, the terms and notices that the setup executable
normally asks for.
Expand All @@ -20,7 +21,7 @@
This parameter is mutually exclusive with the parameter Edition.

.PARAMETER EditionUpgrade
Upgrades the edition of the installed product. Requires that either the
Specifies whether to upgrade the edition of the installed product. Requires that either the
ProductKey or the Edition parameter is also assigned. By default no edition
upgrade is performed.

Expand All @@ -40,7 +41,7 @@
PI Report Server: %ProgramFiles%\Microsoft Power BI Report Server

.PARAMETER SuppressRestart
Suppresses the restart of the computer after the installation is finished.
Specifies whether to suppress the restart of the computer after the installation is finished.
By default the computer is restarted after the installation is finished.

.PARAMETER Timeout
Expand All @@ -49,11 +50,11 @@
this time, an exception will be thrown.

.PARAMETER Force
If specified the command will not ask for confirmation. Same as if Confirm:$false
Specifies whether the command will not ask for confirmation. Same as if Confirm:$false
is used.

.PARAMETER PassThru
If specified the command will return the setup process exit code.
Specifies whether the command will return the setup process exit code.

.OUTPUTS
When PassThru is specified the function will return the setup process exit
Expand Down
12 changes: 6 additions & 6 deletions source/Public/Invoke-SqlDscQuery.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Specifies current server connection object.

.PARAMETER ServerName
Specifies the server name where the instance exist.
Specifies the server name where the instance exists.

.PARAMETER InstanceName
Specifies the instance name on which to execute the T-SQL query.
Expand All @@ -29,21 +29,21 @@
Specifies the name of the database to execute the T-SQL query in.

.PARAMETER Query
The query string to execute.
Specifies the query string to execute.

.PARAMETER PassThru
Specifies if the command should return any result the query might return.
Specifies whether the command should return any result the query might return.

.PARAMETER StatementTimeout
Set the query StatementTimeout in seconds. Default 600 seconds (10 minutes).
Specifies the query StatementTimeout in seconds. Default 600 seconds (10 minutes).

.PARAMETER RedactText
One or more text strings to redact from the query when verbose messages
Specifies one or more text strings to redact from the query when verbose messages
are written to the console. Strings will be escaped so they will not
be interpreted as regular expressions (RegEx).

.PARAMETER Encrypt
Specifies if encryption should be used.
Specifies whether encryption should be used.

.PARAMETER Force
Specifies that the query should be executed without any confirmation.
Expand Down
2 changes: 1 addition & 1 deletion source/Public/New-SqlDscAgentOperator.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
Specifies the weekday pager start time for the SQL Agent Operator.

.PARAMETER PassThru
If specified, the created operator object will be returned.
Specifies whether the created operator object will be returned.

.PARAMETER Force
Specifies that the operator should be created without any confirmation.
Expand Down
2 changes: 1 addition & 1 deletion source/Public/Set-SqlDscAgentAlert.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
Cannot be used together with Severity.

.PARAMETER PassThru
If specified, the updated alert object will be returned.
Specifies whether the updated alert object will be returned.

.PARAMETER Refresh
Specifies that the alert object should be refreshed before updating. This
Expand Down
Loading
Loading