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

P2P-Nathan repair validation errors #19

Merged
merged 9 commits into from Oct 30, 2017
Merged

P2P-Nathan repair validation errors #19

merged 9 commits into from Oct 30, 2017

Conversation

P2P-Nathan
Copy link
Member

Corrected errors that were preventing the validation success.

@P2P-Nathan P2P-Nathan requested a review from a team October 26, 2017 20:15
@P2P-Nathan
Copy link
Member Author

This PR will enable continuous integration testing, results are visible for the test with the inline links or at https://ci.appveyor.com/project/P2P-Nathan/scom-community-catalog/build/1.0.3/tests

Copy link
Contributor

@shadeon shadeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, but some tweaks to the test template are probably necessary to align with best practice.

@@ -47,7 +46,7 @@ foreach ($packFile in $packFiles) {
Context 'details.json' {

It "details.json is valid json" {
{ $contents | ConvertFrom-Json } | Should Not Throw
{$script:json = $contents | ConvertFrom-Json } | Should Not Throw
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the tests order dependant (other tests will fail if this one isn't run first). The original call probably needs a try/catch wrapping it.

@@ -33,18 +32,21 @@ foreach ($packFile in $packFiles) {

It "Has a details.json" {
$packFile.FullName | Should Exist
$packFile.Name | Should BeExactly "details.json"
Copy link
Contributor

@shadeon shadeon Oct 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In AppVeyor and VSCode only the test name is surfaced - can you either update it to include this restriction or (preferably) create another test? Good unit testing practise is to only test a single thing with each test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To increase the readability of the output I'll change the test name to "Has a details.json (case-sensitive)", this should help a user that gets the error even through they have a details.JSON in the folder.

}

It "Has a Readme.md" {
$readme = $packFile.FullName -replace $packFileName, 'README.md'
$readme | Should Exist
# Get-ChildItem is used as Get-Item returns the same case it is passed.
(Get-ChildItem -Path $packFile.DirectoryName -Filter "readme.md").Name | Should BeExactly "ReadMe.md"
Copy link
Contributor

@shadeon shadeon Oct 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In AppVeyor and VSCode only the test name is surfaced - can you either update it to include this restriction or (preferably) create another test? Good unit testing practise is to only test a single thing with each test.

(also, feel free to update my incorrectly cased file name above!)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To increase the readability of the output I'll change the test name to "Has a ReadMe.md (case-sensitive)", this should help a user that gets the error even through they have a README.md in the folder.

@shadeon
Copy link
Contributor

shadeon commented Oct 27, 2017

Might be worth adding this to the top line of the repo readme.md as well:
<img src="https://ci.appveyor.com/api/projects/status/github/MPCatalog/scom-community-catalog?branch=master&svg=true" alt="Project Badge" />

as this will manifest :
Project Badge

@P2P-Nathan
Copy link
Member Author

P2P-Nathan commented Oct 27, 2017 via email

@shadeon
Copy link
Contributor

shadeon commented Oct 27, 2017

Not currently, but it may do in the future. The other danger is simply the tests being re-ordered.

@P2P-Nathan
Copy link
Member Author

P2P-Nathan commented Oct 27, 2017 via email

@shadeon
Copy link
Contributor

shadeon commented Oct 27, 2017

No problem, just locally tested this and it seemed to do the trick

# Even with ErrorAction Silent, this could still throw terminating exceptions
    $json = $null
    try { $json = $contents | ConvertFrom-Json -ErrorAction SilentlyContinue } catch {}

Included feedback from PR into changes
@P2P-Nathan
Copy link
Member Author

The noted changes have been added, and the updated tests have been passed. Waiting for a community moderator to approve, then we can pull it in.

Copy link
Contributor

@shadeon shadeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good 👍

@P2P-Nathan P2P-Nathan merged commit e8bcbf5 into MPCatalog:master Oct 30, 2017
@P2P-Nathan P2P-Nathan deleted the P2P-Nathan-Repair-Validation-Errors branch October 30, 2017 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants