Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
Loading
Loading