Skip to content

SqlScript: Add integration tests with configuration and dependencies#2450

Merged
johlju merged 4 commits intodsccommunity:mainfrom
johlju:fix/SqlScript-integ-test
Feb 7, 2026
Merged

SqlScript: Add integration tests with configuration and dependencies#2450
johlju merged 4 commits intodsccommunity:mainfrom
johlju:fix/SqlScript-integ-test

Conversation

@johlju
Copy link
Member

@johlju johlju commented Feb 6, 2026

Pull Request (PR) description

  • SqlScript
    • Added integration test configuration that creates script files and executes
      the resource in a single configuration using DependsOn.

This Pull Request (PR) fixes the following issues

None.

Task list

  • Added an entry to the change log under the Unreleased section of the
    file CHANGELOG.md. Entry should say what was changed and how that
    affects users (if applicable), and reference the issue being resolved
    (if applicable).
  • Resource documentation updated in the resource's README.md.
  • Resource parameter descriptions updated in schema.mof.
  • Comment-based help updated, including parameter descriptions.
  • Localization strings updated.
  • Examples updated.
  • Unit tests updated. See DSC Community Testing Guidelines.
  • Integration tests updated (where possible). See DSC Community Testing Guidelines.
  • Code changes adheres to DSC Community Style Guidelines.

This change is Reviewable

@johlju johlju requested a review from a team as a code owner February 6, 2026 19:27
@coderabbitai
Copy link

coderabbitai bot commented Feb 6, 2026

Walkthrough

Adds 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

Cohort / File(s) Summary
Changelog
CHANGELOG.md
Added an Unreleased "Changed" subsection documenting the SqlScript integration test configuration that creates script files and executes the resource using DependsOn.
Test Configurations
tests/Integration/Resources/DSC_SqlScript.config.ps1
Added Database4Name to config data; added public configurations DSC_SqlScript_RunSqlScriptAsWindowsUserWithDependencies_Config (creates supporting files, configures SqlScript resource with DependsOn, uses Windows user credentials) and DSC_SqlScript_RemoveDatabase4_Config (cleanup/removal).
Integration Tests
tests/Integration/Resources/DSC_SqlScript.Integration.Tests.ps1
Added two new test contexts exercising the RunSqlScriptAsWindowsUserWithDependencies and RemoveDatabase4 workflows, including MOF compile/apply, Get-DscConfiguration parsing/validation, and Test-DscConfiguration checks.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding integration tests with configuration and dependencies for SqlScript.
Description check ✅ Passed The description is directly related to the changeset, explaining the addition of integration test configuration for SqlScript using DependsOn.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and TestSqlScriptPath — the same random file paths consumed by the earlier configurations (RunSqlScriptAsWindowsUser_Config, RunSqlScriptAsSqlUser_Config, RunSqlScriptWithVariablesDisabled_Config). Because the xScript TestScript blocks 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
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94%. Comparing base (78a2c04) to head (f915da3).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #2450   +/-   ##
=====================================
  Coverage     94%     94%           
=====================================
  Files        227     227           
  Lines      10778   10778           
=====================================
  Hits       10149   10149           
  Misses       629     629           
Flag Coverage Δ
unit 94% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member Author

@johlju johlju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@johlju reviewed 3 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @johlju).

@johlju
Copy link
Member Author

johlju commented Feb 7, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Feb 7, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@johlju johlju merged commit 875f868 into dsccommunity:main Feb 7, 2026
40 checks passed
@johlju johlju deleted the fix/SqlScript-integ-test branch February 7, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant