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

Fix for mockCall.Unset() panic (issue #1236) #1239

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

DubbaThony
Copy link

@DubbaThony DubbaThony commented Jul 27, 2022

Summary

This PR aims to fix #1236. While it's not the pretties fix, it avoids panic

Changes

Within Unset function instead of iterating over an slice and removing items from it at same time, a temporary slice is created, during iteration orginal logic is used to decide if the item should be removed, and if not, item is added to temporary slice.
After iteration temporary slice overrides orginal slice, preventing panic.

Motivation

As library user, I want this function to work.

Related issues

Closes #1236

This PR aims to fix stretchr#1236. While it's not the pretties fix, it avoids panic

Motivation:
As library user, I want this function to work.

Example usage:
n/a

Feature or bug fix?
Bug fix
@DubbaThony DubbaThony changed the title Fix for #1236 Fix for mockCall.Unset() panic (issue #1236) Aug 10, 2022
@dolmen dolmen added bug pkg-mock Any issues related to Mock mock.ArgumentMatcher About matching arguments in mock labels Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mock.ArgumentMatcher About matching arguments in mock pkg-mock Any issues related to Mock
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mockCall.Unset cause panic
2 participants