Skip to content

How should I test Body Binding in my application? #2526

@joaoschoen

Description

@joaoschoen

I'm writing an API using echo and adding tests to it as I go, and I've found a problem that I don't know how to solve

In every single request that requires the binding of a body to a struct I have to add a test case for if the binding fails

var loginInfo model.UnsafeUser
  if err := echo.Bind(&loginInfo); err != nil {
  return echo.JSON(http.StatusBadRequest, "Bad username and password combination")
}

Something like this bit of code above, do you guys have any solution for it other then just adding the same test to every single test file?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions