SqlScript: Add integration tests with configuration and dependencies#2450
SqlScript: Add integration tests with configuration and dependencies#2450johlju merged 4 commits intodsccommunity:mainfrom
Conversation
WalkthroughAdds integration test configurations and test cases for the SqlScript DSC resource that run scripts as a Windows user with DependsOn-linked file-creation resources, plus a cleanup configuration to remove the added test database. Changes
Sequence Diagram(s)sequenceDiagram
participant Tester as Tester (Pester)
participant Compiler as Configuration Compiler
participant LCM as Local Configuration Manager
participant FS as File System
participant SQL as SQL Server
rect rgba(200,200,255,0.5)
Tester->>Compiler: Invoke configuration (create MOF)
Compiler-->>Tester: MOF produced
end
rect rgba(200,255,200,0.5)
Tester->>LCM: Start DSC configuration (Apply MOF)
LCM->>FS: Ensure file creation resources (Create Get/Test/Set scripts)
FS-->>LCM: Files created
LCM->>SQL: Execute SqlScript resource as Windows user
SQL-->>LCM: Script executed (create/modify DB)
LCM-->>Tester: Apply complete
end
rect rgba(255,200,200,0.5)
Tester->>LCM: Get-DscConfiguration / Test-DscConfiguration
LCM-->>Tester: Resource states and Test result
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@CHANGELOG.md`:
- Around line 8-12: The changelog entry under "Changed" for SqlScript needs an
issue reference; edit the SqlScript bullet to append the issue link in the
required format — e.g., add "([issue
#<issue_number>](https://github.com/<owner>/<repo>/issues/<issue_number>))"
after the sentence about the integration test configuration (which mentions
DependsOn) so the entry reads the same but includes the referenced issue link.
🧹 Nitpick comments (1)
tests/Integration/Resources/DSC_SqlScript.config.ps1 (1)
298-414: Shared script file paths may cause test-order coupling.The new configuration reuses
GetSqlScriptPath,SetSqlScriptPath, andTestSqlScriptPath— the same random file paths consumed by the earlier configurations (RunSqlScriptAsWindowsUser_Config,RunSqlScriptAsSqlUser_Config,RunSqlScriptWithVariablesDisabled_Config). Because the xScriptTestScriptblocks compare file content and the SQL scripts reference$(DatabaseName)(unchanged across configs), the file content written by this config is identical, so this works today. However, if the script content ever diverges per config, the shared paths will silently cause cross-contamination between test contexts.This is fine for now given the intentional design, but consider documenting the shared-path assumption in a comment.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2450 +/- ##
=====================================
Coverage 94% 94%
=====================================
Files 227 227
Lines 10778 10778
=====================================
Hits 10149 10149
Misses 629 629
🚀 New features to boost your workflow:
|
johlju
left a comment
There was a problem hiding this comment.
@johlju reviewed 3 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @johlju).
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Pull Request (PR) description
the resource in a single configuration using
DependsOn.This Pull Request (PR) fixes the following issues
None.
Task list
file CHANGELOG.md. Entry should say what was changed and how that
affects users (if applicable), and reference the issue being resolved
(if applicable).
This change is