Skip to content

Conversation

@TimCurwick
Copy link
Contributor

Fix ConvertTo-Html single matched column header bug
Add ConvertTo-Html pester tests for single matched column header bug

Fix ConvertTo-Html single matched column header bug
Add ConvertTo-Html pester tests for single matched column header bug
@msftclas
Copy link

msftclas commented Sep 4, 2016

Hi @TimCurwick, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by Microsoft and real humans are currently evaluating your PR.

TTYL, MSBOT;

@TimCurwick
Copy link
Contributor Author

TimCurwick commented Sep 4, 2016

Fixes issue #2185
There were no tests for ConvertTo-Html. I added a test file with two tests specific to the modified behavior. I presume Microsoft has other, existing tests for ConvertTo-Html that can and should also be run before merging.


[Cmdlet(VerbsData.ConvertTo, "Html", DefaultParameterSetName = "Page",
HelpUri = "https://go.microsoft.com/fwlink/?LinkID=113290", RemotingCapability = RemotingCapability.None)]
HelpUri = "http://go.microsoft.com/fwlink/?LinkID=113290", RemotingCapability = RemotingCapability.None)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you revert this to https please. TLS connections should be the default for URLs.

@mirichmo
Copy link
Member

mirichmo commented Sep 8, 2016

@adityapatwardhan Please take a look. This fix is specific to Windows PowerShell (full CLR) because the cmdlet has not yet been ported to CoreCLR.

$customPSObject = [pscustomobject]@{ "prop1" = "val1"; "prop2" = "val2" }

It "Test ConvertTo-Html header with default single property" -Skip:( $IsLinux -or $IsOSX -or $IsCoreCLR ) {
$returnObject = $customPSObject | Select prop1 | ConvertTo-Html
Copy link
Member

Choose a reason for hiding this comment

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

Select [](start = 42, length = 6)

Do not use aliases in tests. Use select-object instead.

@adityapatwardhan
Copy link
Member

@TimCurwick please fix the two small comments in the tests. Rest looks good.

@daxian-dbw
Copy link
Member

@TimCurwick could you please address the 2 comments and rebase your commits? ConvertTo-Html has been enabled in powershell core.

@TimCurwick
Copy link
Contributor Author

Sorry about the delay. I was on vacation and then busy with the Summit. Airports are great for catching up on work. :)

@adityapatwardhan
Copy link
Member

@TimCurwick Seems that there are merge conflicts in test/powershell/Modules/Microsoft.PowerShell.Utility/ConvertTo-Html.Tests.ps1. Could you resolve those please?

@adityapatwardhan
Copy link
Member

@TimCurwick Commit# 6b1ecd4 also has merge conflicts.

@chunqingchen
Copy link
Contributor

chunqingchen commented Jan 11, 2017

please resolve the build conflict. It's still there

@PowerShellTeam PowerShellTeam added the Review - Needed The PR is being reviewed label Jan 11, 2017
@TravisEz13 TravisEz13 removed the Stale label Feb 16, 2017
@mirichmo
Copy link
Member

I am trying to clean out old PRs and this one looks potentially useful.

@JamesWTruher or @dantraMSFT - Can one or both of you review this change and provide feedback? Also, please confirm that it is still relevant and has not already been fixed.

If you guys approve of it, I'll guide it in for a landing.


function normalizeLineEnds([string]$text)
{
$text -replace "`r`n?|`n", "`r`n"
Copy link
Collaborator

@JamesWTruher JamesWTruher May 18, 2017

Choose a reason for hiding this comment

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

$text -replace "${newLine}?|`n","${newLine}"

might be better, or could the line endings be removed entirely? Is that part of what you're looking to validate?

<title>HTML TABLE</title>
</head><body>
<table>
<colgroup><col/><col/><col/></colgroup>
Copy link
Collaborator

Choose a reason for hiding this comment

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

i sure wish we could replicate less code - create variables and reuse them?


It "Test ConvertTo-Html with no parameters" {
$returnObject = $customObject | ConvertTo-Html
$returnObject -is [System.Array] | Should Be $true
Copy link
Collaborator

Choose a reason for hiding this comment

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

this test isn't really needed, right? isn't the test on line 30 enough?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the test is appropriate; however, it would be easier to diagnose if Type.FullName is compared instead of a soft-cast.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should Be $true is an anti-pattern - the logs aren't very useful so try to avoid that.

In this case, you can use 'Should BeOfType`. See the list of Pester assertions here.

And I'll be honest - I'm surprised it's an array - I would have expected a single string, so from that point of view, it might be worth a test to at least make it obvious if someone were to implement my expected behavior.

@mi-hol
Copy link

mi-hol commented Jun 27, 2017

@TimCurwick are you planning to implemented the requested changes?
@JamesWTruher should the label 'Review - needed' be replaced with another one?

@mirichmo
Copy link
Member

I replaced this PR with PR #4276

@mirichmo mirichmo closed this Jul 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review - Needed The PR is being reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.