-
-
Notifications
You must be signed in to change notification settings - Fork 144
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
316 assert functions #350
316 assert functions #350
Conversation
I need to look at this when I have a little more time. I would rather keep the functions in separate files to enable reuse |
I've added few more tests so it is more obvious what functions we will have. Function reuse is obviously a good thing to have, but I don't see how the My argument with Get-DatabaseDetail (perhaps the name could be changed) is only ever to be used in the database tests. If we had better scopes in PowerShell I would put all the |
I brought this branch up to date with the latest developments in the development branch. Any comments on the way we want to go with this? I'm eager to write more tests and make the checks faster but there is the question about reuse. @SQLDBAWithABeard, @potatoqualitee, @AnyBody? |
apologies for the delay, I need to sit with a clear head for this one to make sure we go the right way forward |
The only thing that concerns me here is this reduces the ease of contributing. But I do love the speed increase you mentioned. I'm just not sure how to make it easier for the casual developer. Should the impacted tests have some code comments above to ease people in? |
So I've been thinking... here is how I see it today We have number of (somehow conflicting) requirements
The above are in the order of priority as I see it (today). Also, to be able to implement number 2 above we need to use Currently the checked in code structure was mostly influenced by points 1, 2, 5 and to some extent 4 making it a bit confusing for new contributors. To increase accessibility I propose we do the following
@potatoqualitee I think that would make the structure easy to explain with logical split of code between three files per group of checks. What do you think? /checks/ that is how it would look like |
now the Database.Tests.ps1 actually works
…a/dbachecks into 316-assert-functions
I have reorganised the files adding some comments to, just to illustrate my suggestions from the previous comment. Any thoughts? There is still the matter of where the Get-DatabaseDetail go which I haven't addressed in those latest changes, and I will need to spend some more time testing before this branch can be merged, but I hope this change helps in the discussion |
Thats a perfect place for get-databasedetail |
Please have a look at the page verify and auto close checks. I have just realised that with the proposed structure it is easy to validate configuration parameters to avoid surprises with checks passing (or failing) because of a typo in the config. It will also allow to cleanup the configuration keys like Lastly (for this comment) I would like to discuss the file structure. Keeping the checks in as few files as possible might make sense because of how the Pester works, or how easy it is to browse through them. But the unit tests file? It is becoming less and less manageable with the |
Now with the reduced 'the sea of green' effect, could we perhaps consider splitting the I'm bringing it up here, because I think the backup checks will be a bit out of scope for what I'm doing here in this PR, and splitting the file, even if only by extracting the backup checks, would make it easier to eventually merge all those changes. What do you think? |
Issue #435 made me think about supporting older versions of SQL Server. I can only test 2008 R2 to 2017. For the changes I have implemented so far it won't be very difficult as I will simply use the I thnk I will have to implement this change before we think about merging this PR |
the code has significantly changed since the review.
So here it is, I think it is time to close this very long standing PR. I opened it almost 6 weeks ago. Since then there was a lot of discussions around the idea of how to better validate the checks, 66 commits, I had 4 different implementations (3rd one is the winner if anybody cares). It was very helpful for me, and I hope it wasn't too annoying for you. (And I must say I really liked how those long PRs allow for frequent code reviews and collaboration, so watch out!) But the time has come to close it down. As agreed with @SQLDBAWithABeard at some point next week I will create a new branch directly in sqlcollaborative rather than in my own fork, and merge all the changes there. Then I will ask for a few volunteers to help to test it before the new PR will be created and hopefully at some point in April we'll get it out. |
As you are probably aware I struggled through the weekend with testing the checks. Then certain SQL DBA with a Bear(d) pointed me to http://jakubjares.com/2017/12/07/testing-your-environment-tests/ (thank you, you know who you are ;) )
In this PR I have
Before we merge this PR I'd like to discuss the new files, namely the
internal/checks/Database.ps1
and previously createdinternal/functions/Get-DatabaseDetail.ps1
.In Jakub's article he keeps the Assert-* function next to the tests. In my opinion it increases code readability as at a quick glance one knows what the check is actually testing. The problem with this is, that you must (as far as I can tell) keep the check tests in the same file as otherwise you will have to include (dot reference) the checks file from the check tests file which is executed by pester, which triggers all of the checks. To solve that problem I have created
internal/checks/Database.ps1
files where I intend to place all theAssert-*
function and include that file in bothchecks/Database.Tests.ps
andtests/Database.Tests.ps1
. That is how it is right now and it works.But now the checks are effectively spread across 3 files: the checks, the assert function and the
interna/functions/Get-DatabaseDetail.ps1
which will only ever be used in the database checks. So I was thinking, wouldn't it make sense to put it in theinternal/checks/Database.ps1
with theAssert-*
functions?What do you think?