Skip to content

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

Open
DubbaThony wants to merge 3 commits intostretchr:masterfrom
DubbaThony:patch-1
Open

Fix for mockCall.Unset() panic (issue #1236)#1239
DubbaThony wants to merge 3 commits intostretchr:masterfrom
DubbaThony:patch-1

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