Repository navigation
feat: publish a stateful fake dokku for embedder tests - #666
Merged
Merged
Conversation
The task catalog now publishes a `lifecycle` per task naming the state that applies its resource and the state that tears it down, and the sdk exposes it as `sdk.TaskLifecycle` alongside `sdk.TaskInState`, which moves a task into a state with the fields that state refuses reset to their defaults. Apply is `set` when offered and the state's default otherwise, teardown is `clear`, else `absent`, and imperative tasks have none. `dokku_storage_ensure` is the one exception: it offers `absent` but refuses it, so it declares no teardown. Each task's reference page now shows its lifecycle.
The new `sdk/dokkutest` package holds apps, config, domains, ports, buildpacks, process scale, plugin properties and datastore services, answers the commands the core tasks send in the formats their probes parse, applies their changes, records every call, and fails any command it does not model. A test drives every covered task type through create, refresh and destroy against it, and another runs every catalog example of those tasks so the fake stays in step with the probes.
The sdk tests and examples that scripted dokku's answers, and the observed fixtures for the tasks the fake models, now seed a fake server instead, so they stay in step with the probes. Failure cases answer the one command they fail with a handler, and the observed fixtures for tasks the fake does not model keep their scripted responses.
josegonzalez
force-pushed
the
650-dokkutest
branch
from
October 22, 2026 03:48
dd61734 to
fd299db
Compare
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.
The new
sdk/dokkutestpackage is a stateful fake dokku. It holds apps, config, domains, ports, buildpacks, process scale, plugin properties and datastore services with their info and links, answers the commands the core tasks send in the formats their probes parse, applies their changes, records every call, and fails any command it does not model with an error naming it and a failed test. It coversdokku_app,dokku_config,dokku_domains,dokku_ports,dokku_buildpacks,dokku_ps_scale, every property-tabledokku_*_propertytask,dokku_service_createanddokku_service_link, plus the version gate and the parent app or service probes.Handle,HandlePrefixandFallbackanswer anything else, andExitandUnavailablefail a command the way dokku or a missing binary would.A test drives each covered type through create, refresh (
ReadTaskandReadAddress) and destroy, asserting on the resulting state, and a guard test plans, applies, reads and exports every catalog example of every covered task against a seeded fake, failing on any command it does not model. The Makefile and CI test lines now cover./sdk/..., and the "Testing without a server" section of docs/embedding.md and the sdk package doc describe the fake.The second commit moves docket's own fakes onto it: the sdk tests and examples that scripted dokku's answers, and the internal/tasks observed fixtures for the tasks the fake models. Failure cases answer the one command they fail with a handler. The observed fixtures for tasks the fake does not model keep their scripted responses, and
ExampleContextWithRunnerkeeps its hand-written runner since it documents that seam.The fake's engine lives in
internal/fakedokku, importing onlyinternal/subprocess, andsdk/dokkutestaliases it and reads the property tables fromsdk.Catalog(). A package that importssdkcannot be used by the in-package tests of internal/tasks without an import cycle, so the engine could not sit insdk/dokkutestitself. A missing app answers with dokku's exit code 20, as the dokku 0.38.31 devcontainer does, and the fake adds no domains or links on its own.Closes #650