Skip to content

Inconsistent nature of messageFromMsgAndArgs #1679

Description

@Antonboom

Description

Hello, team!

I was surprised, but testify allows to set non-string in msgAndArgs... if this is the single argument:

if len(msgAndArgs) == 1 {
msg := msgAndArgs[0]
if msgAsStr, ok := msg.(string); ok {
return msgAsStr
}
return fmt.Sprintf("%+v", msg)
}

So I can do

assert.Equal(a, b, new(time.Time))

But cannot

assert.Equal(a, b, new(time.Time), 1, 2, 3) // Panics.

Proposed solution

Remove support of non-string single arg (as rare and strange? case) and allows only msg string + args ...any.

Use case

f-assertions future (#1089 (comment)).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions