Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix ConvertTo-Html single matched column header bug#2184

Closed
TimCurwick wants to merge 4 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
TimCurwick:masterCopy head branch name to clipboard
Closed

Fix ConvertTo-Html single matched column header bug#2184
TimCurwick wants to merge 4 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
TimCurwick:masterCopy head branch name to clipboard

Conversation

@TimCurwick

Copy link
Copy Markdown
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

msftclas commented Sep 4, 2016

Copy link
Copy Markdown

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

TimCurwick commented Sep 4, 2016

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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

mirichmo commented Sep 8, 2016

Copy link
Copy Markdown
Member

@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
Copy Markdown
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
Copy Markdown
Member

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

@daxian-dbw

Copy link
Copy Markdown
Member

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

@TimCurwick

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

@TimCurwick Commit# 6b1ecd4 also has merge conflicts.

@chunqingchen

chunqingchen commented Jan 11, 2017

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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"

@JamesWTruher JamesWTruher May 18, 2017

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

mi-hol commented Jun 27, 2017

Copy link
Copy Markdown

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

@mirichmo

Copy link
Copy Markdown
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.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.