Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import-SqlDscPreferredModule: Fix re-evaluate PSModulePath #1938

Merged
merged 1 commit into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Re-enable integration tests for dbatools.
- Bumped dbatools to v2.0.1 for the integration tests.

### fixed

- `Import-SqlDscPreferredModule`
- Now when parameter `Force` is passed the command correctly invoke
`Get-SqlDscPreferredModule` using the parameter `Refresh`.

## [16.3.1] - 2023-05-06

### Changed
Expand Down
5 changes: 5 additions & 0 deletions source/Public/Import-SqlDscPreferredModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ function Import-SqlDscPreferredModule
$getSqlDscPreferredModuleParameters.Name = @($Name, 'SQLPS')
}

if ($PSBoundParameters.ContainsKey('Force'))
{
$getSqlDscPreferredModuleParameters.Refresh = $true
}

$availableModuleName = Get-SqlDscPreferredModule @getSqlDscPreferredModuleParameters

if ($Force.IsPresent)
Expand Down
5 changes: 4 additions & 1 deletion tests/Unit/Public/Import-SqlDscPreferredModule.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ Describe 'Import-SqlDscPreferredModule' -Tag 'Public' {
It 'Should import the SqlServer module without throwing' {
{ Import-SqlDscPreferredModule -Force } | Should -Not -Throw

Should -Invoke -CommandName Get-SqlDscPreferredModule -Exactly -Times 1 -Scope It
Should -Invoke -CommandName Get-SqlDscPreferredModule -ParameterFilter {
$PesterBoundParameters.ContainsKey('Refresh') -and $Refresh -eq $true
} -Exactly -Times 1 -Scope It

Should -Invoke -CommandName Push-Location -Exactly -Times 1 -Scope It
Should -Invoke -CommandName Pop-Location -Exactly -Times 1 -Scope It
Should -Invoke -CommandName Remove-Module -Exactly -Times 1 -Scope It
Expand Down