8000 Add test for -WhatIf for New-FileCatalog by mjanko5 · Pull Request #8966 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Add test for -WhatIf for New-FileCatalog#8966

Merged
iSazonov merged 6 commits intoPowerShell:masterfrom
mjanko5:newfilecatalog-whatif
Feb 27, 2019
Merged

Add test for -WhatIf for New-FileCatalog#8966
iSazonov merged 6 commits intoPowerShell:masterfrom
mjanko5:newfilecatalog-whatif

Conversation

@mjanko5
Copy link
Contributor
@mjanko5 mjanko5 commented Feb 24, 2019

PR Summary

fixes #2866.
Implemented by @mjanko5 (me) and @MarekZietek with the guidance of @TylerLeonhardt and @rjmholt at HackIllinois 2019.

PR Context

The new code adds a second parameter to the ShouldProcess method to CatalogCommands.cs, which makes -WhatIf work for the New-FileCatalog command.

PR Checklist

{
PerformAction(paths, catalogFilePath);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove this newline


if (ShouldProcess(catalogFilePath))
string action = StringUtil.Format(Modules.CreatingModuleManifestFile, catalogFilePath);

Copy link
Collaborator

Choose a reason for hiding this comment

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

No need for this newline

$result | Should -Be "Valid"
}

It "TestCatalogWhatIfForNewFileCatalog"{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
It "TestCatalogWhatIfForNewFileCatalog"{
It "New-FileCatalog -WhatIf does not create file" {

Copy link
Member

Choose a reason for hiding this comment

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

The rest of the file has the smooshed test titles... do you think we should move away from what the rest of the file does, @rjmholt?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Generally speaking in newer tests we opt for not smooshing them. Probably this test file should have a followup PR to make the test titles more readable across the whole file when we're done here. 🙂

}

if (ShouldProcess(catalogFilePath))
string action = StringUtil.Format(Modules.CreatingModuleManifestFile, catalogFilePath);
Copy link
Member

Choose a reason for hiding this comment

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

I noticed here you are using the

Modules.CreatingModuleManifestFile

property which comes from the file:

PowerShell/src/System.Management.Automation/resources/Modules.resx

Rather than using that one, you should add a new entry in that resx file called like CreatingFileCatalog

and use it instead.

NOTE: In order to rebuild the resx files... instead of running

Start-PSBuild
you run
Start-PSBuild -Clean

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually @TylerLeonhardt if all you're doing is regenerating your resx files you want to Start-PSBuild -ResGen

But yeah clean build is easy and covers it for ya. 😄

@iSazonov
Copy link
Collaborator

I wonder if this fix works. If it works it is a tricky bug in ShouldProcess() and it is better fix the bug.
We can see implementation in src\System.Management.Automation\engine\MshCommandRuntime.cs
And I'd use debugger to understand how the code works.

@TylerLeonhardt
Copy link
Member

@iSazonov the fix does work (hence the added test). And I agree with you that the underlying bug should be investigated and fixed.

That said, one thing that this fix does is align the ShouldProcess call to the same call as New-ModuleManifest which does a similar action.

So I still think this PR is valid.

The student also followed up on the original issue regarding this bug in ShouldProcess

@iSazonov
Copy link
Collaborator
iSazonov commented Feb 24, 2019

the fix does work (hence the added test).

The test is passed without the fix.
And I can not repo with example from source issue.

@mjanko5
Copy link
Contributor Author
mjanko5 commented Feb 24, 2019

@TylerLeonhardt @rjmholt @iSazonov @vexx32 Looks like there is a conversation about our code update / PR. However, I will leave at that here, and look forward to working with your team in the future. Thanks to Rob and Tyler for their mentorship and guidance at the hackathon. I learned a lot about PowerShell, GitHub, and open source.

@iSazonov
Copy link
Collaborator
iSazonov commented Feb 25, 2019

@TylerLeonhardt @rjmholt Can you repro? If no please close the PR.

@rjmholt
Copy link
Collaborator
rjmholt commented Feb 25, 2019

This already seems to work in 6.2.0-preview.4.

@rjmholt rjmholt closed this Feb 25, 2019
@TylerLeonhardt
Copy link
Member

The test addition is worth something...

@rjmholt rjmholt added the Hacktoberfest Potential candidate to participate in Hacktoberfest label Feb 25, 2019
@rjmholt rjmholt reopened this Feb 25, 2019
@rjmholt rjmholt force-pushed the newfilecatalog-whatif branch from 30f5498 to 2bcc1cf Compare February 25, 2019 19:51
@rjmholt rjmholt force-pushed the newfilecatalog-whatif branch from 3cd968d to ea4f4df Compare February 25, 2019 19:53
@rjmholt
Copy link
Collaborator
rjmholt commented Feb 25, 2019

Have patched this up

@iSazonov iSazonov added the CL-Test Indicates that a PR should be marked as a test change in the Change Log label Feb 26, 2019
@iSazonov iSazonov self-assigned this Feb 26, 2019
@TylerLeonhardt TylerLeonhardt changed the title Make -WhatIf work for New-FileCatalog Add test for -WhatIf for New-FileCatalog Feb 26, 2019
@iSazonov iSazonov merged commit 7e0411f into PowerShell:master Feb 27, 2019
@daxian-dbw daxian-dbw added this to the 6.2.0 milestone Mar 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Test Indicates that a PR should be marked as a test change in the Change Log Hacktoberfest Potential candidate to participate in Hacktoberfest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New-FileCatalog ignores -WhatIf

6 participants

0