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

SqlServiceAccount: Unit tests fail to run on a machine without SQL Server installed #983

Closed
johlju opened this issue Dec 30, 2017 · 0 comments · Fixed by #1235
Closed

SqlServiceAccount: Unit tests fail to run on a machine without SQL Server installed #983

johlju opened this issue Dec 30, 2017 · 0 comments · Fixed by #1235
Assignees
Labels
bug The issue is a bug.

Comments

@johlju
Copy link
Member

johlju commented Dec 30, 2017

Details of the scenario you tried and the problem that is occurring:
When running the unit tests for the resource SqlServiceAccount, the tests fail becuase it cannot find a registry key. This is probably due to that a mock is missing.

Get-ChildItem : Cannot find path 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Services' because it does not exist.
At C:\Source\SqlServerDsc\DSCResources\MSFT_SqlServiceAccount\MSFT_SqlServiceAccount.psm1:409 char:30
+ ... rviceTypeDefinition = Get-ChildItem -Path $serviceRegistryKey | Where ...
+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (HKEY_LOCAL_MACH...Server\Services:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

      [-] Should have the correct Type for the service 252ms
        ArgumentException: Unknown or unsupported service type 'DatabaseEngine' specified!
        Parameter name: ServiceType
        at New-InvalidArgumentException, C:\Source\SqlServerDsc\DscResources\CommonResourceHelper.psm1: line 37
        at Get-SqlServiceName, C:\Source\SqlServerDsc\DSCResources\MSFT_SqlServiceAccount\MSFT_SqlServiceAccount.psm1: line 431
        at Get-ServiceObject, C:\Source\SqlServerDsc\DSCResources\MSFT_SqlServiceAccount\MSFT_SqlServiceAccount.psm1: line 282
        at <ScriptBlock>, C:\Source\SqlServerDsc\Tests\Unit\MSFT_SqlServiceAccount.Tests.ps1: line 585

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

@johlju johlju added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. labels Dec 30, 2017
johlju added a commit to johlju/SqlServerDsc that referenced this issue Sep 28, 2018
- Fix unit tests that didn't mock some of the calls. It no longer fail
  when a SQL Server installation is not present on the node running the
  unit test (issue dsccommunity#983).
@johlju johlju added in progress The issue is being actively worked on by someone. and removed help wanted The issue is up for grabs for anyone in the community. labels Sep 28, 2018
@johlju johlju self-assigned this Sep 28, 2018
johlju added a commit that referenced this issue Sep 28, 2018
…1235)

- Changes to SqlServiceAccount
  - Fix unit tests that didn't mock some of the calls. It no longer fail
    when a SQL Server installation is not present on the node running the
    unit test (issue #983).
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Sep 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant