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

Feature Request: TestDrive for Registry #402

Closed
robbiepc30 opened this issue Aug 15, 2015 · 9 comments · Fixed by #1112
Closed

Feature Request: TestDrive for Registry #402

robbiepc30 opened this issue Aug 15, 2015 · 9 comments · Fixed by #1112
Assignees
Labels

Comments

@robbiepc30
Copy link

One thing that I have been doing frequently in my scripts is writing to the registry. I've been using mocking to unit test anything that I write to the registry and it has worked well, but after using TestDrive in some of my scripts for writing and deleting files I keep wishing that I could do the same thing with the registry.

I was wondering if anyone else would be interested in seeing a feature like TestDrive for the Registry, and if its possible, could we see that as an added feature some time in the future.

@robbiepc30 robbiepc30 changed the title TestDrive for Registry Feature Request: TestDrive for Registry Aug 15, 2015
@megamorf
Copy link

I think one could implement that with transactions since they don't write to the registry directly until you commit the changes with Complete-Transaction

http://blogs.technet.com/b/heyscriptingguy/archive/2015/04/23/using-transactions-with-powershell-registry-provider.aspx

@nohwnd
Copy link
Member

nohwnd commented Aug 15, 2015

That should be quite easy to implement, the test drive is just folder in Temp that has uniquely generated name. This folder is then mapped to the TestDrive PS Provider. You can do the same with registry.

The only thing that would be a bit clumsy is that the Pester is not very modular at its core, so you need to setup and tear down the registry folder for each describe.

@JacodeWeerd
Copy link

I am starting to use Pester on PowerShell modules that do a lot of writing and reading to the registry. A testdrive for the registry would be great and would simplify the tests.
Thank you in advance!

@bwright86
Copy link

I am in the same boat with you all, doing some registry work and starting to use Pester for testing it. It would be nice to spin up a new test drive pointed to a hive file object in the $env:Temp path as well, something like TempReg: or HKTR:.

Might just look at what it takes to spin up a registry hive in the Describe block, and tear it down afterwards.

@sam-bryant
Copy link

I also came across the need for this functionality. +1

@fjahn78
Copy link

fjahn78 commented Apr 9, 2018

I second the request. Also for an ActiveDirectory test drive +1

@nohwnd
Copy link
Member

nohwnd commented Apr 9, 2018

@fschumann1211 AD test drive is not going to happen, we would have to take dependency on the AD cmdlets, and install a real domain per-test :)) The registry test drive I'd like to implement, but unfortunately I have so little free time :/

@nohwnd nohwnd self-assigned this Apr 9, 2018
@andikrueger
Copy link
Contributor

I'm also looking for a way to test registry reads and writes. I could start to implement something similar to TestDrive, but see an issue with cross platform compatibility. Linux doesn't have something comparable. See:

function Get-TempDirectory
{
if ((GetPesterOs) -eq 'Windows')
{
$env:TEMP
}
else
{
'/tmp'
}
}

I pushed my current changes to this branch and am looking forward to your (@nohwnd) feedback about the OS compatibility.

@nohwnd
Copy link
Member

nohwnd commented Oct 6, 2018

@andikrueger looks good, I quickly read through it and don't see any obvious problems. Please make a PR from that branch. :) I'd like to test the clean-up a bit more, and see what is the impact on performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants