Ejemplo
plug 1.20.3: Test a Plug router end to end with Plug.Test, with no HTTP server, no socket and no network
Muestra verificada para hex plug 1.20.3: Test a Plug router end to end with Plug.Test, with no HTTP server, no socket and no network. El contrato se ejecutó…
sha256:f7cb5b2f102e81a511f97af235bf61218cafe9e3bac8f599cb824293963da6c0
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 2
- Claves de firma que lo compilaron
- 2
Entorno declarado
elixir 1 linux x64 elixir 1 elixir mix
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| elixir 1 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 | PASS | compile:PASS · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · hex@1 |
2026-08-14 |
| elixir 1 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:PASS · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · hex@1 |
2026-08-18 |
Caso
HOW- Objetivo
- Test a Plug router end to end with Plug.Test, with no HTTP server, no socket and no network
- Paquetes
- Símbolos
-
- Plug.Test.conn
- Plug.Test.sent_resp
- Plug.Router
- Plug.Parsers
- Plug.Conn.send_resp
- Plug.Conn.put_resp_content_type
- Plug.Conn.AlreadySentError
- Plug.Parsers.UnsupportedMediaTypeError
- Plug.Conn.Unfetched
- Entorno
- elixir 1
- Creado
- 2026-08-14T09:41:26Z
Contrato
- assert the test conn is an in-process struct with a fabricated loopback peer, and that the deprecated conn.owner field is nil because the owning pid lives in the adapter payload
- assert conn.status is nil and conn.state is :unset before the router runs, and 200/:sent after
- assert sent_resp reports a sent response and raises for one that resp/3 only staged
- assert a route binds its path segment as a variable in the route body
- assert an unmatched path is 404 only because match _ exists, and a router without it raises FunctionClauseError
- assert the method is part of the match, so a POST to a GET route falls through to 404
- assert Plug.Parsers is what turns a JSON body into conn.body_params, and that params merges the query string while body_params does not
- assert a top-level JSON array arrives under the _json key
- assert that without Plug.Parsers body_params stays Plug.Conn.Unfetched, which raises ArgumentError on a bare conn but reads back as nil through a router because :match overwrites conn.params
- assert a content type listed in :pass reaches a route unparsed with body_params still the Unfetched placeholder, while one in neither :parsers nor :pass raises Plug.Parsers.UnsupportedMediaTypeError
- assert a map body passed to conn/3 is written straight into body_params as multipart/mixed, skipping the parser entirely, and that read_body returns a placeholder
- assert send_resp and put_resp_header raise Plug.Conn.AlreadySentError once the response is sent
- assert put_resp_content_type appends charset=utf-8 and stores a lowercase header name that get_resp_header matches exactly
Archivos
- csx.json
- lib/csx_plug/raw_router.ex
- lib/csx_plug/router.ex
- mix.exs
- mix.lock
- test/contract_test.exs
- test/test_helper.exs