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

Added new VSCodeInsiders class with Pester tests #60

Merged
merged 8 commits into from
Oct 2, 2024

Conversation

Gijsreyn
Copy link
Contributor

@Gijsreyn Gijsreyn commented Sep 27, 2024


Addresses issue #59

Comment on lines -93 to -95
# Keeps the path of the code.exe CLI path.
$VSCodeCLIPath = Get-VSCodeCLIPath

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 it might be better to add a boolean parameter like $UseInsiders instead of creating a completely new DSC resource. That way we don't have to maintain two resources that are essentially doing the same thing.

You can use the boolean parameter inside the static constructor to check if $UseInsiders = $true and set $VSCodeCLIPath with the correct insiders code.exe path. So basically:

if $UseInsiders
{
    $VSCodeCLIPath = Get-VSCodeInsidersCLIPath
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ryfu-msft Thanks for the review. This is exactly what I wanted to do in the first place, but couldn't grasp my head around it. My class-based PowerShell development is a bit frisky.

Wouldn't it require to add an additional property in the class, allowing the ability to choose between Insiders or Stable?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup, you would need to add another boolean DSCProperty and use that to determine whether we point to the Insiders or Stable VSCodeCLI path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ryfu-msft Hey Ryan, I've rewritten the Get-VSCodeCLIPath (also started on the custom path one from #61 ). I'm struggling with how to get it initialized. Whenever Initialize is called, a loop occurs. I'm seeing something over the head. Do you mind taking a look?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After struggling for some time now, I reconstructed the constructors. Because of the following logic when calling Invoke-DscResource:

image

The call is made later to determine the CLI path. The export has an overload added. It's good to check if this is possible with dsc.exe I guess.

resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psd1 Outdated Show resolved Hide resolved
resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 Outdated Show resolved Hide resolved
resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 Outdated Show resolved Hide resolved
resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 Outdated Show resolved Hide resolved
Comment on lines -112 to 130
{
[VSCodeExtension]::GetInstalledExtensions()
VSCodeExtension() {
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm okay with moving GetInstalledExtensions() to the get method. Since we are no longer using a static constructor, this can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ryfu-msft I didn't totally get what you mean what is required to be removed.

resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 Outdated Show resolved Hide resolved
resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 Outdated Show resolved Hide resolved
tests/Microsoft.VSCode.Dsc/Microsoft.Windows.Dsc.Tests.ps1 Outdated Show resolved Hide resolved
@ryfu-msft
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Gijsreyn
Copy link
Contributor Author

Gijsreyn commented Oct 2, 2024

Can you run the pipeline once more?

@ryfu-msft
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@ryfu-msft ryfu-msft left a comment

Choose a reason for hiding this comment

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

These should fix your issues with the test. Be sure to actually run the tests on your machine before submitting.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename this to Microsoft.VSCode.Dsc.Tests.ps1

tests/Microsoft.VSCode.Dsc/Microsoft.Windows.Dsc.Tests.ps1 Outdated Show resolved Hide resolved
tests/Microsoft.VSCode.Dsc/Microsoft.Windows.Dsc.Tests.ps1 Outdated Show resolved Hide resolved
tests/Microsoft.VSCode.Dsc/Microsoft.Windows.Dsc.Tests.ps1 Outdated Show resolved Hide resolved
tests/Microsoft.VSCode.Dsc/Microsoft.Windows.Dsc.Tests.ps1 Outdated Show resolved Hide resolved
tests/Microsoft.VSCode.Dsc/Microsoft.Windows.Dsc.Tests.ps1 Outdated Show resolved Hide resolved
resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 Outdated Show resolved Hide resolved
resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 Outdated Show resolved Hide resolved
resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 Outdated Show resolved Hide resolved
resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 Outdated Show resolved Hide resolved
@Gijsreyn
Copy link
Contributor Author

Gijsreyn commented Oct 2, 2024

These should fix your issues with the test. Be sure to actually run the tests on your machine before submitting.

Sorry Ryan, was struggling with the Pester version and getting it running. Should be fixed now. Can you run it once more?

@ryfu-msft
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@ryfu-msft ryfu-msft left a comment

Choose a reason for hiding this comment

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

Looks great! Huge thank you for this contribution 😄 and for the tests.

@ryfu-msft ryfu-msft merged commit f020e3f into microsoft:main Oct 2, 2024
4 checks passed
@Gijsreyn
Copy link
Contributor Author

Gijsreyn commented Oct 3, 2024

And you thanks for the checks. Looking forward to seeing the custom path coming :)

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.

2 participants