Documentation
¶
Overview ¶
Package server is mock-wms: a small HTTP service that behaves like the warehouse system for the test stand.
Input: POST /reservations (reserve the lines of an order), POST /reservations/{external_id}/release (undo it), POST /shipments (ship an order), and GET /reservations?external_id= and GET /shipments?external_id= (lookups). Output: JSON. It writes only to its own schema mock_wms, so that a test can count effects with a query.
A request with an external_id that is already there changes nothing and answers 200 with the stored row (an idempotent receiver). A release is idempotent too: it releases what is there and does nothing for what is not.
A shipment is the fact of the warehouse: it records the quantity that left (the ordered quantity times MOCK_SHIP_QTY_FACTOR) and one SSCC per line, derived from the external id so that the same shipment always has the same labels.
Fault knobs (from the environment, or set by tests): the share of requests that commit and then answer 500, a fixed delay, a business reference prefix that gets a permanent refusal (422; for shipments only, so that a reservation can succeed and be compensated), and the quantity factor of a shipment.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
FailAfterCommitRate float64 // MOCK_FAIL_AFTER_COMMIT_RATE: 0 to 1
Latency time.Duration // MOCK_LATENCY_MS
RejectRefPrefix string // MOCK_REJECT_REF_PREFIX: shipments of an order with this prefix get 422
ShipQtyFactor string // MOCK_SHIP_QTY_FACTOR: decimal multiplier of the shipped quantity; "" means 1
}
Config holds the fault knobs.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the HTTP handler of the mock.
func (*Server) SetRejectRefPrefix ¶
SetRejectRefPrefix changes the prefix of business references whose shipment gets a 422.
func (*Server) SetShipQtyFactor ¶
SetShipQtyFactor changes the multiplier of the shipped quantity.