Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Requires Elixir 1.15 or higher.

All public functions in `TestServer` have been moved to `TestServer.HTTP`. The
HTTP server adapters in `TestServer.HTTPServer.*` have been moved to
`TestServer.HTTP.Server.*`.
`TestServer.HTTP.Server.*`. `add/2` has been renamed to `handle/2`, and `websocket_info/2` has been renamed to `websocket_send/2` and now takes options as second argument.

TestServer now has SSH support with `TestServer.SSH`.

- Fixed bug where `:match` functions that raised errors always matched in `TestServer.HTTP.add/2` and `TestServer.HTTP.websocket_handle/3`
- Fixed bug where `:match` functions that raised errors always matched in `TestServer.HTTP.handle/2` and `TestServer.HTTP.websocket_handle/2`
- Fixed UTF-8 response body handling for `TestServer.HTTP.Server.Httpd`
- Fixed invalid host header port parsing in `TestServer.HTTP.Server.Httpd`
- Fixed bracketed IPv6 host header parsing in `TestServer.HTTP.Server.Httpd`
Expand Down
50 changes: 50 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Contributing

Thanks for considering contributing to TestServer!

## Test suite

TestServer supports several HTTP server adapter. The adapter is selected via the `HTTP_SERVER` environment variable:

```bash
HTTP_SERVER=Bandit mix test
HTTP_SERVER=Plug.Cowboy mix test
HTTP_SERVER=Httpd mix test
```

CI runs the [full matrix](.github/workflows/ci.yml) across `Bandit`, `Plug.Cowboy`, and `:httpd`.

## Code quality

Elixir formatter, `Credo`, and `:dialyzer` are used:

```bash
mix compile --warnings-as-errors
mix format --check-formatted
mix credo --strict
mix dialyzer
```

## Protocol architecture

TestServer consists of different protocols with normally these functions:

* `start(options)` - Starts the instance the server
* `stop(instance)` - Stops the server and the instance
* `handle(instance, options)` - Adds an expectation handler. Takes `:to` and `:match` function option.

If the protocol is bidirectional you would also have:

* `send(instance, options)` - Sends message to the active process and handles the reply the same way as `handle`. Takes `:to` function option.

### Option conventions

- Options should mirror the underlying OTP option names verbatim when it makes sense (e.g. `:ipfamily` or `:no_auth_needed`)
- Options should otherwise use Elixir conventions like snake case (`:listen_options`, `:recv_timeout`).

## Submitting a PR

- Write a focused pull request description and link any related issue
- Update `CHANGELOG.md` under `## Unreleased`
- If behavior changes, add or update tests
- Ensure the full adapter matrix passes locally before pushing
Loading
Loading