Skip to content

Commit

Permalink
Import-SqlDscPreferredModule: Correctly fix re-evaluate PSModulePath
Browse files Browse the repository at this point in the history
  • Loading branch information
johlju committed May 8, 2023
1 parent d296853 commit 50dfb85
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
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

0 comments on commit 50dfb85

Please sign in to comment.