Skip to content

Need negative unit tests #78

Closed

Description

@aaron-junot

#70 added a bunch of tests for the routes, but it only tests the happy path (what's supposed to happen). We need "negative" unit tests that test that the app fails gracefully and as expected based on bogus input. In those situations where HTML is returned instead of JSON, or the api returns a 500 instead of a 400 series error, the route should be modified such that it will return the expected/required input. When someone puts in a PR for a negative unit test that requires a change of behavior, we can discuss in that PR what the exact behavior we want ought to be.

Acceptance criteria:

Each route should have a few negative unit tests with bogus input. The test should verify that JSON is returned (preferably with a helpful error message). The API should never return HTML, so unit tests should verify a valid JSON response. No error should leak any information about our database. The HTTP status code returned should be as specific as possible (e.g., a 422 is favored over a 400 when invalid input is returned).

Activity

  1. thinkingserious commented on Oct 23, 2019

    @thinkingserious
    Contributor

    I can take this one, thanks!

  2. aaron-junot commented on Oct 23, 2019

    @aaron-junot
    MemberAuthor

    Ok @thinkingserious thanks! Most of the newer routes have negative unit tests. I'm mostly concerned with the Create and Update Resources endpoints because those are the ones that actually make changes to the data. We want to make sure that with bogus input, or super long input, or potentially problematic input like strange characters and emojis, the app is resilient enough to handle it

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions