Domain-driven error handling. Don't handle errors - prevent them. ThinkingElixir 023: Gleam and Static Types with Louis Pilfold

Introducing MockMe Hex Package

MockMe

This last week I published a Hex package for mocking third party APIs. This package starts a real http server when your tests run that mimics the third party api you’re connecting to. This allows you to easily write integration tests which test your entire code path as it would perform in production, complete with real HTTP requests and responses.

Use is as simple as defining a list of routes and running your tests.

    %MockMe.Route{
      name: :swapi_starships,
      path: "/swapi/starships/:id",
      responses: [
        %MockMe.Response{
          flag: :success,
          body: MockMePhoenixExample.Test.Mocks.SWAPI.starships(:success)
        },
        %MockMe.Response{flag: :not_found, body: "starship-not-found", status_code: 404}
      ]
    }```

I hope you find this pattern as useful as I have.