dsccommunity / dsccommunity/SqlServerDsc

SqlServerDscHelper: Tests throws exception 'The type name 'Microsoft.SqlServer.Management.Smo.LoginCreateOptions' already exists'

Open
#899 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
PowerShell
Stars
385
Forks
224
PR merge metrics
No merged PRs in 30d

Description

Details of the scenario you tried and the problem that is occurring:
If you run the xSQLServerHelper tests twice in the same PowerShell session. When starting all tests with Invoke-Pester then xSQLServerHelper throws the exception below.

Executing script V:\Source\xSQLServer\Tests\Unit\xSQLServerHelper.Tests.ps1
  [-] Error occurred in test script 'V:\Source\xSQLServer\Tests\Unit\xSQLServerHelper.Tests.ps1' 164ms
    Exception: Cannot add type. The type name 'Microsoft.SqlServer.Management.Smo.LoginCreateOptions' already exists.
    at <ScriptBlock>, V:\Source\xSQLServer\Tests\Unit\xSQLServerHelper.Tests.ps1: line 20
    at <ScriptBlock>, C:\Program Files\WindowsPowerShell\Modules\Pester\4.0.8\Pester.psm1: line 802
    at Invoke-Pester<End>, C:\Program Files\WindowsPowerShell\Modules\Pester\4.0.8\Pester.psm1: line 817
    at <ScriptBlock>, <No file>: line 1

The DSC configuration that is using the resource (as detailed as possible):
n/a

Version of the Operating System, SQL Server and PowerShell the DSC Target Node is running:
n/a

What module (SqlServer or SQLPS) and which version of the module the DSC Target Node is running:
n/a

Version of the DSC module you're using, or 'dev' if you're using current dev branch:
Dev

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Tests/Unit/xSQLServerHelper.Tests.ps1, especially line 20, and run the xSQLServerHelper tests twice in the same PowerShell session with Invoke-Pester. Trace the type-loading setup and ensure the second run completes without the duplicate Microsoft.SqlServer.Management.Smo.LoginCreateOptions exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, sql
Domain
databases, testing-qa
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.