Skip to content

Commit

Permalink
SqlTraceflag: Correctly loads the SMO assemblies (#1682)
Browse files Browse the repository at this point in the history
- SqlTraceFlag
  - Fixed Assembly not loaded error (issue #1680).
  • Loading branch information
Fiander authored Jan 30, 2021
1 parent 8a040bf commit 511b365
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- SqlTraceFlag
- Fixed Assembly not loaded error
([issue #1680](https://github.com/dsccommunity/SqlServerDsc/issues/1680)).

### Changed

- SqlLogin
Expand Down
6 changes: 6 additions & 0 deletions source/DSCResources/DSC_SqlTraceFlag/DSC_SqlTraceFlag.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ function Get-TargetResource
$InstanceName
)

# Import SqlServer module.
Import-SQLPSModule

Write-Verbose -Message (
$script:localizedData.GetConfiguration -f $InstanceName
)
Expand Down Expand Up @@ -145,6 +148,9 @@ function Set-TargetResource
$RestartTimeout = 120
)

# Import SqlServer module.
Import-SQLPSModule

Write-Verbose -Message (
$script:localizedData.SetConfiguration -f $InstanceName
)
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/DSC_SqlTraceFlag.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ Server\MSSQL15.INST00\MSSQL\DATA\mastlog.ldf
return @($mockServerObject)
}
Mock -CommandName New-Object -MockWith $mockSmoWmiManagedComputer -ParameterFilter $mockNewObject_ParameterFilter_RealServerName -Verifiable
Mock -CommandName Import-SQLPSModule
}

Context 'For the default instance' {
Expand Down Expand Up @@ -353,6 +354,7 @@ Server\MSSQL15.INST00\MSSQL\DATA\mastlog.ldf
return @($mockServerObject)
}
Mock -CommandName New-Object -MockWith $mockSmoWmiManagedComputer -Verifiable
Mock -CommandName Import-SQLPSModule
}

Context 'When the system is not in the desired state and TraceFlags is empty' {
Expand Down Expand Up @@ -646,6 +648,7 @@ Server\MSSQL15.INST00\MSSQL\DATA\mastlog.ldf
}
Mock -CommandName New-Object -MockWith $mockSmoWmiManagedComputer -Verifiable
Mock -CommandName Restart-SqlService -ModuleName $script:dscResourceName -Verifiable
Mock -CommandName Import-SQLPSModule
}

Context 'When the system is not in the desired state and ensure is set to Absent' {
Expand Down

0 comments on commit 511b365

Please sign in to comment.