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

Update New-MockObject examples to use type object as input #2609

Merged
merged 4 commits into from
Jan 20, 2025

Conversation

fflaten
Copy link
Collaborator

@fflaten fflaten commented Jan 17, 2025

PR Summary

Updates New-MockObject with examples for using type objects to reference classes.
Fix #2564

PR Checklist

  • PR has meaningful title
  • Summary describes changes
  • PR is ready to be merged
    • If not, use the arrow next to Create Pull Request to mark it as a draft. PR can be marked Ready for review when it's ready.
  • Tests are added/update (if required)
  • Documentation is updated/added (if required)

@fflaten
Copy link
Collaborator Author

fflaten commented Jan 17, 2025

CI failing, but works on my machine (and devcontainer). Help, someone? 😅

Index was out of range. Must be non-negative and less than or equal to the size of the collection. (Parameter 'index')

The line is $obj = [MyInternalClass]::new() - what index?

@fflaten fflaten marked this pull request as draft January 17, 2025 20:42
@nohwnd
Copy link
Member

nohwnd commented Jan 17, 2025

I also don't see it locally, some kind of confusion where [] is misinterpreted as indexing operator? I vaguely remember this as being some problem somewhere.

@nohwnd
Copy link
Member

nohwnd commented Jan 17, 2025

I know what is it now :P

@nohwnd
Copy link
Member

nohwnd commented Jan 17, 2025

you yourself told me what to do last time, and I saw it recently in zlocation, the bug with classes when running under coverage / profiler.

@fflaten
Copy link
Collaborator Author

fflaten commented Jan 17, 2025

Yeah, was about to add the ctor and a comment myself. Forgot CI runs with CC

@fflaten fflaten marked this pull request as ready for review January 17, 2025 21:30
@fflaten
Copy link
Collaborator Author

fflaten commented Jan 17, 2025

/backport to rel/5.x.x

Copy link

Started backporting to rel/5.x.x: https://github.com/pester/Pester/actions/runs/12837313182

@nohwnd nohwnd merged commit 856f2be into pester:main Jan 20, 2025
11 checks passed
nohwnd added a commit that referenced this pull request Jan 20, 2025
…in #2609 (backport to rel/5.x.x) (#2611)

* Add New-MockObject example and tests for internal class

* Wrap test in version check for easier backport

* fix something please

* Add default ctors to make code run under Profiler

* Fix tests for PowerShell 3/4

---------

Co-authored-by: Frode Flaten <[email protected]>
Co-authored-by: Jakub Jareš <[email protected]>
@fflaten fflaten deleted the newmockobject-help branch January 20, 2025 10:37
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.

Cant use New-MockObject with custom class from within a module
2 participants