Added --http-upgrade and --direct to ws-test dial, so it can connect to job-search serve or ws-test serve

One of the two is required. --http-upgrade upgrades an HTTP connection to
a WebSocket on /ws, as before, for job-search serve; --url and --origin go
with it. --direct connects straight to ws-test serve over plain TCP, one
JSON message per line, at --addr (default from server.host and
server.port). --ping, --message, --listen and stdin work the same in both
modes. The README's ws-test section explains the two modes.
This commit is contained in:
bwilliams committed 2026-10-16 09:47:38 +01:00
1 parent 88f879d844
commit f0c171c8a8
5 files changed
+506 -60

No files matched your search

+14 -5
View File
@@ -110,13 +110,22 @@ See [internal/mock](internal/mock/README.md) for its options and behaviour.
## WebSocket test tool
`ws-test` reads the same configuration as `job-search` for its defaults:
```bash
go run ./cmd/ws-test dial --ping # ping the HTTP server's /ws endpoint
go run ./cmd/ws-test dial # send each line of stdin, print replies
go run ./cmd/ws-test serve # plain TCP server for websocket hub clients
go run ./cmd/ws-test dial --http-upgrade --ping # ping job-search serve's /ws endpoint
go run ./cmd/ws-test dial --direct --ping # ping ws-test serve
go run ./cmd/ws-test dial --http-upgrade # send each line of stdin, print replies
go run ./cmd/ws-test serve # plain TCP server for websocket hub clients
```
`dial` also takes `--message`, `--listen`, `--origin` (to test the Origin
check), `--url` and `--timeout`; see `ws-test dial --help`.
`dial` needs one of `--http-upgrade`, to upgrade an HTTP connection to a
WebSocket on `/ws` as `job-search serve` expects, or `--direct`, to connect
straight to `ws-test serve` over plain TCP with one JSON message per line.
It also takes `--message`, `--listen` and `--timeout`; `--url` and `--origin`
(to test the Origin check) with `--http-upgrade`, and `--addr` with
`--direct`. See `ws-test dial --help`.
`ws-test serve` is a test server only: don't run it alongside
`job-search serve`. Both listen on `server.host` and `server.port`, so the
second one fails with "address already in use".
## Project layout