-
Notifications
You must be signed in to change notification settings - Fork 88
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
Added the ability to change the power options on the network adapter #219
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #219 +/- ##
===================================
- Coverage 96% 94% -2%
===================================
Files 17 18 +1
Lines 1276 1358 +82
===================================
+ Hits 1228 1285 +57
- Misses 48 73 +25 |
Now what? |
Hi @edycus - there are a few issues that are causing the tests to fail - nothing major though:
Finally, there is a test coverage issue that needs to be fixed - e.g. we need to increase unit test coverage by about 49 lines, but I can make some suggestions around that once the other stuff is done. I'll also do a proper code review as well and make some suggestions on that. Thanks for all your help and I appreciate the work on this - it can be a bit of a steep learning curve but well worth it and I'm happy to help! |
Thanks you for the help. I see it is stilling failing one test. I can't see what the error is. What do I need to do next? |
@PlagueHO what next? |
@edycus - I'm not seeing a failing unit test. What I am seeing is a failure in the code coverage. You'll need to write unit tests for this in order for us to keep our code coverage up. As @PlagueHO noted though you have a few style violations, specifically as he called out in item 4. Are you familiar with how to write unit tests or is this something we can help you get started? |
I am not sure what a unit test is. I will need some help to get me started.
…-------- Original message --------
From: "Tyson J. Hayes" <notifications@github.com>
Date: 7/11/17 6:13 PM (GMT-08:00)
To: PowerShell/xNetworking <xNetworking@noreply.github.com>
Cc: edycus <eric.dycustemp1@outlook.com>, Mention <mention@noreply.github.com>
Subject: Re: [PowerShell/xNetworking] Added the ability to change the power options on the network adapter (#219)
@edycus<https://github.com/edycus> - I'm not seeing a failing unit test. What I am seeing is a failure in the code coverage. You'll need to write unit tests for this in order for us to keep our code coverage up. As @PlagueHO<https://github.com/plagueho> noted though you have a few style violations, specifically as he called out in item 4.
Are you familiar with how to write unit tests or is this something we can help you get started?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#219 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AOO2OuMjmXMPCXndn_th1ypCenaB3PTeks5sNB21gaJpZM4N9BWL>.
|
Hi @edycus - a unit test is a type of automated test that lets us validate that the code behaves as intended. This is a good post that summarizes the different types of tests: These unit tests run every time code is commited to this repo and validate that the code is working correctly and also helps prevent regression problems (changes that cause other unintended problems or bugs). We use a test framework for PowerShell called Pester to perform the testing (it makes it much easier). You can find all the unit tests in files named \tests\unit\MSFT_*.tests.ps1. E.g. https://github.com/PowerShell/xNetworking/tree/dev/Tests/Unit You'll want to create a unit test file for your resource - e.g \tests\unit\MSFT_xNetPowerManagement.tests.ps1 and add Pester tests to test the behavior of each *-TargetResource function. Writing tests can be a little bit difficult, but it is a very useful skill to have (especially as the industry is talking about unit testing infrastructure using these frameworks). So it is worth persevering with. I can help you if you get stuck, but see if this info helps you make a start and we'll go from there! Your work on this is really appreciated! |
Thank you for the information. I hae some questions as I try to get my head around it. I'm looking at MSFT_xNetconnectionProfile.tests.ps1 as an example of how a test should look.
Let just take the first describe which analysis the Get-NetPowerManagement. I changed it to use my variables
What is suppose to work? I'm feeding it parameters to test against the system. My main question is AdapterType and State are variables, how is the code below suppose to be used when the state is unknown. My guess is, this is just a try statement and it's just looking for an error condition?
Describe "MSFT_xNetPowerManagement\Get-TargetResource" {
Mock Get-NetPowerManagement {
return @{
AdapterType = 'Ethernet 802.3'
State = $true
}
}
$expected = @()
$expected.AdpaterType = 'Ethernet 802.3'
$expected.State = $true
$result = Get-TargetResource -InterfaceAlias $expected.InterfaceAlias
It 'Should return the correct values' {
$expected.AdpaterType | Should Be $result.AdapterType
$expected.State | Should Be $result.State
}
}
…________________________________
From: Daniel Scott-Raynsford <notifications@github.com>
Sent: Tuesday, July 11, 2017 7:21:41 PM
To: PowerShell/xNetworking
Cc: edycus; Mention
Subject: Re: [PowerShell/xNetworking] Added the ability to change the power options on the network adapter (#219)
Hi @edycus<https://github.com/edycus> - a unit test is a type of automated test that lets us validate that the code behaves as intended.
This is a good post that summarizes the different types of tests:
https://blogs.technet.microsoft.com/heyscriptingguy/2015/12/16/unit-testing-powershell-code-with-pester/
These unit tests run every time code is commited to this repo and validate that the code is working correctly and also helps prevent regression problems (changes that cause other unintended problems or bugs). We use a test framework for PowerShell called Pester<https://github.com/pester/Pester> to perform the testing (it makes it much easier).
You can find all the unit tests in files named \tests\unit\MSFT_*.tests.ps1. E.g. https://github.com/PowerShell/xNetworking/tree/dev/Tests/Unit
You'll want to create a unit test file for your resource - e.g \tests\unit\MSFT_xNetPowerManagement.tests.ps1 and add Pester tests to test the behavior of each *-TargetResource function.
Writing tests can be a little bit difficult, but it is a very useful skill to have (especially as the industry is talking about unit testing infrastructure using these frameworks). So it is worth persevering with. I can help you if you get stuck, but see if this info helps you make a start and we'll go from there!
Your work on this is really appreciated!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#219 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AOO2OnYBw9_w-prp65o22Ze-_JoeMiWIks5sNC21gaJpZM4N9BWL>.
|
@PlagueHO I have resubmitted. I defiantly need some help with the test side of this. I don't fully understand how to test. Do I need to download pester? |
Hi @edycus - writing unit tests is definitely one of the hardest parts to creating DSC resource (and PowerShell in general), but an awesome skill worth having (some of our teams use Pester tests to validate servers are configured correctly and working as expected as well as testing code). Anyway, you do need to have the Pester PowerShell module installed. E.g.
I actually wrote a blog series a couple of years back on getting started with DSC contributions and it had a section on testing. Have a look at this page: https://dscottraynsford.wordpress.com/2015/12/18/creating-professional-dsc-resources-part-4/ I can also give you a hand constructing the tests as well. Have a look at the blog post and see if that explains anything in more detail. |
One more thing: Are you using Visual Studio Code to edit in? You should - it's free and by far the best tool for working with PS in my opinion 😁 It'll allow you to auto-format your code to the style guidelines of the DSC Resource Kit automatically. Just open the file and press SHIFT+ALT+F and it'll correct much of the style issues (otherwise I'd need to comment on them to get you to fix them and I'm being lazy 😁 ). Make sure you've got the PowerShell extension installed into Visual Studio Code too (otherwise the SHIFT+ALT+F won't work). |
@PlagueHO I am using Visual studio but the get-hub connection is a little foreign to me. If I go to File, Open , File and select MSFT_xNetPowerManagement.psm1. The only thing SHIFT+ALT+F does is open up my file menu at the top. LOL. What am I missing here? |
@edycus - ahhhh! That's Visual Studio 2015 (or 2017 maybe). Visual Studio Code is different - it's a very lightweight cross platform IDE from Microsoft. It looks a bit different. Like this: |
I see that I changed the code in my github site. Do I have to submit another pull request? |
Never mind. I see it running now |
I am taking off for today. Thanks for your help. The pieces are starting to fit together. |
@edycus If you want to learn Pester, The Pester Book is very good source explaining it. I recommend it to anyone wanting to learn Pester. |
Hi @edycus - just wondered if you needed any help on this one? I'm happy to give you a hand implementing the tests. |
Yes, please. Any help is appreciated
…-------- Original message --------
From: Daniel Scott-Raynsford <notifications@github.com>
Date: 12/8/17 9:35 PM (GMT-08:00)
To: PowerShell/xNetworking <xNetworking@noreply.github.com>
Cc: edycus <eric.dycustemp1@outlook.com>, Mention <mention@noreply.github.com>
Subject: Re: [PowerShell/xNetworking] Added the ability to change the power options on the network adapter (#219)
Hi @edycus<https://github.com/edycus> - just wondered if you needed any help on this one? I'm happy to give you a hand implementing the tests.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#219 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AOO2OmVNs_Xkt-6igmE0-0CbWwSr_d7Qks5s-hwugaJpZM4N9BWL>.
|
@edycus - sure thing! What I could do is submit a PR to your dev branch with the tests. I'll take a look at doing this when I can (next few weeks if time permits). |
Labeling this PR as abandoned since it has gone 14 days or more since the last update. An abandoned PR can be continued by another contributor. The abandoned label will be removed if work on the PR is taken up again. |
It appears I have still yet to submit some tests to your branch @edycus - so this is mostly waiting on me. I'll try and resuscitate this one when I have time. |
Closing because abandoned |
This change is