feat(sandbox): Phase 0 MVP — local HTTP mock server from OpenAPI spec#73
Merged
Conversation
Fix ResponseGenerator to guarantee a non-empty UUID id for write ops when the schema strategy returns an empty string for the id field.
… in cleanup runWithSandbox now returns a non-nil error when any test fails so CI exits non-zero. resetGenGlobals in the e2e test helper now resets genWithSandbox.
AT-301: sandbox GET /pets returns 200
AT-302: full CRUD flow POST→GET/{id}→DELETE returns 201/200/204
AT-303: gen --with-sandbox flag is registered
- cmd/gen.go: fix BASE_URL → base_url to match hurl renderer's {{base_url}}
placeholder; the mismatch caused --with-sandbox to send requests to an
unresolved literal URL, making every run fail.
- scripts/acceptance.sh: promote AT-303 from --help grep to a real end-to-end
gen+sandbox+hurl run using a success-only spec and --technique
equivalence_partitioning so only happy-path cases are exercised.
Add skip/random_port helpers; replace Linux-only shuf with portable $RANDOM.
…tion
caseforge run --target and caseforge conformance --target both injected
BASE_URL into hurl's --variable flag. Hurl is case-sensitive and its
renderer emits {{base_url}} (lowercase), so the variable was never
substituted and every request hit a literal unresolved URL.
- cmd/run.go: inject base_url for hurl runner, BASE_URL for k6 runner
- cmd/conformance.go: inject base_url (always uses hurl runner)
- Update help text to clarify the per-format convention
…ADME - Add caseforge sandbox to Workflow commands table - Add --with-sandbox to gen Command Reference flags - Add caseforge sandbox Command Reference section with flags, startup message, stateful CRUD behaviour, and CI vs interactive guidance
…ails, CI tip - Document auto strategy chain (example → schema → faker) - Add sandbox vs gen --with-sandbox use-case guidance - Document X-Sandbox-ID response header and LIST behaviour - Add Ctrl-C / graceful shutdown note - Add CI one-shot recipe: --technique equivalence_partitioning + success-only spec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
internal/sandbox/package: stateful in-memory mock HTTP server driven by an OpenAPI speccaseforge sandbox --spec <path>command for interactive dev/debug usecaseforge gen --with-sandboxflag for CI one-shot validate-without-a-real-backendWhat's included
internal/sandbox/sandbox.goOptionsstruct + defaultsstate.goStateStoreinterface +memStateStore(RWMutex-guarded, concurrent-safe)strategies.goExampleStrategy → SchemaStrategy → FakerStrategychaingenerator.goResponseGenerator: tries strategies, guarantees non-emptyidon write opslogging.gomultiHandlerfanningslogrecords to stderr (text) + file (JSON);buildLoggerhandler.gomakeHandler: per-operationhttp.HandlerFunc(DELETE/GET/POST-PUT-PATCH)server.goSandboxServer:Start(random port vianet.Listen),Shutdown,Addr*_test.gohttptestcmd/sandbox.gocaseforge sandbox --spec api.yaml [--port N] [--host H] [--log-level info|warn|error|silent] [--log-file path] [--format auto|schema|faker]Prints
caseforge sandbox listening on http://127.0.0.1:<port>on startup; SIGINT/SIGTERM → graceful shutdown.cmd/gen.go--with-sandbox: starts sandbox in-process on a random port, injects--variable base_url=…into hurl runner, runs generated cases, returns non-zero exit if any test fails.Test plan
go test -race ./...— 256 unit + integration tests pass, no data races./scripts/acceptance.sh— 256/256 pass, including:caseforge sandbox—GET /petsreturns 200gen --with-sandboxflag is registeredOut of scope (Phase 1)