Skip to content

Conversation

@segogoreng
Copy link

Summary

Continues work from #1049 by @matinFT.
This PR rebases with the latest master, fixes according the original PR's comments by @dolmen , and also add NotKind to adhere to the API convention.
This fixes #633

Changes

Add Kind and NotKind function in assert package.

Motivation

See #633

Related issues

Closes #633

@segogoreng segogoreng marked this pull request as draft September 29, 2025 03:50
@segogoreng segogoreng marked this pull request as ready for review September 29, 2025 03:56
@segogoreng segogoreng mentioned this pull request Sep 29, 2025
Copy link
Collaborator

@dolmen dolmen left a comment

Choose a reason for hiding this comment

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

Incomplete test suite.

if h, ok := t.(tHelper); ok {
h.Helper()
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

The case where expectedKind == reflect.Invalid must be rejected (and added to test cases).

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for catching this.
I've updated to handle this

h.Helper()
}

objectKind := reflect.TypeOf(object).Kind()
Copy link
Collaborator

Choose a reason for hiding this comment

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

object must be checked for nil and rejected before calling reflect.TypeOf (another missing test case).

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for catching this.
I've updated to handle this

if h, ok := t.(tHelper); ok {
h.Helper()
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same issues as in Kind:

  • check for reflect.Invalid expectedKind
  • check for nil object

Copy link
Author

Choose a reason for hiding this comment

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

Updated, thank you.

@dolmen dolmen added enhancement pkg-assert Change related to package testify/assert enhancement: extend API An enhancement that grows the API surface pkg-require Change related to package testify/require labels Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement: extend API An enhancement that grows the API surface enhancement pkg-assert Change related to package testify/assert pkg-require Change related to package testify/require

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Method to check if return is a function

3 participants