Skip to content

feat: add CheckedClose test helper#27217

Merged
gwossum merged 1 commit into1.12from
gw/checkedclose_1.12
Feb 13, 2026
Merged

feat: add CheckedClose test helper#27217
gwossum merged 1 commit into1.12from
gw/checkedclose_1.12

Conversation

@gwossum
Copy link
Copy Markdown
Member

@gwossum gwossum commented Feb 12, 2026

  • feat: add CheckedClose test helper

Add CheckedClose test helper to improve readability of the following pattern in tests.

defer func() {
    require.NoError(t, c.Close())
}()

This can now be replaced with defer CheckedClose(t, c)().

  • feat: add CheckedCloseOnce

Add CheckedCloseOnce test helper function to create close functions that check for errors and only call the underlying Close method once.

Clean chery-pick from master-1.x.

(cherry picked from commit 093bd3f)

* feat: add CheckedClose test helper

Add CheckedClose test helper to improve readability of the following
pattern in tests.
```
defer func() {
    require.NoError(t, c.Close())
}()
```

This can now be replaced with `defer CheckedClose(t, c)()`.

* feat: add CheckedCloseOnce

Add CheckedCloseOnce test helper function to create close functions
that check for errors and only call the underlying Close method once.

Clean chery-pick from master-1.x.

(cherry picked from commit 093bd3f)
@gwossum gwossum self-assigned this Feb 12, 2026
@gwossum gwossum marked this pull request as ready for review February 12, 2026 23:29
@gwossum gwossum merged commit 0f3436d into 1.12 Feb 13, 2026
10 checks passed
@gwossum gwossum deleted the gw/checkedclose_1.12 branch February 13, 2026 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants