FakeDockerEngine class final
An in-memory DockerEngine for tests.
Published so that rig modules and rig_cli can test against it. It models
only what rig asks of Docker: create, start, inspect, list, stop, remove,
pull, logs.
- Implemented types
Constructors
- FakeDockerEngine({EngineVersion versionInfo = const EngineVersion(version: '29.5.3', apiVersion: '1.54', minApiVersion: '1.40')})
Properties
- buildFailureDetail ↔ String
-
getter/setter pair
- buildSucceeds ↔ bool
-
When false, buildImage throws ImageBuildFailed.
getter/setter pair
-
calls
→ List<
String> -
Every call, in order:
create,start:<id>,stop:<id>, ...final - hashCode → int
-
The hash code for this object.
no setterinherited
-
healthAfterCreate
↔ List<
HealthStatus> -
What a container created through createContainer reports for health,
in order, holding the last value once exhausted.
getter/setter pair
-
images
→ Set<
String> -
Images that imageExists reports as present.
final
- lastBuild ↔ ContainerBuild?
-
The arguments of the last buildImage call, for assertions.
getter/setter pair
- lastBuildTag ↔ String?
-
getter/setter pair
-
lastCreatedLabels
↔ Map<
String, String> ? -
getter/setter pair
- lastCreatedSpec ↔ ContainerSpec?
-
The last createContainer arguments, for assertions.
getter/setter pair
- nextHostPort ↔ int
-
The first host port handed out; incremented per published port.
getter/setter pair
-
onExec
↔ ExecResult Function(List<
String> command) -
Answers exec. Defaults to success with no output.
getter/setter pair
- pingError ↔ Object?
-
When set, ping throws it.
getter/setter pair
- pullFailureDetail ↔ String
-
getter/setter pair
- pullSucceeds ↔ bool
-
When false, pullImage throws ImagePullFailed.
getter/setter pair
- removeError ↔ Object?
-
When set, removeContainer throws it instead of removing anything.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- versionInfo ↔ EngineVersion
-
getter/setter pair
Methods
-
addContainer(
{required Map< String, String> labels, String image = 'scratch:latest', String state = 'running', DateTime? created, Map<int, int> hostPorts = const {}, List<HealthStatus> health = const [], String logs = '', String? network}) → String - Adds a container that already exists, as if a previous run left it.
-
addDirectory(
String id, String path) → void -
Makes
idbehave as ifpathalready exists as a directory, so a test can exercise putArchive without going through a realmkdir. The root/is already present on every container. -
addFile(
String id, String path, List< int> content) → void -
Seeds
idwith a file atpath, so a test can exercise getArchive (viaContainerLease.getFile) without a prior putArchive. -
addNetwork(
{required String name, Map< String, String> labels = const {}, List<String> connectedContainerIds = const []}) → String -
Adds a network as if a previous run left it, for tests that exercise
rig prune's network cleanup without going through ensureNetwork or createContainer. -
addRawArchive(
String id, String path, List< int> tarBytes) → void -
Makes getArchive return
tarBytesverbatim forpath, instead of wrapping single-file content the way it normally does. -
buildImage(
ContainerBuild build, String tag) → Future< void> -
Builds an image from
buildand tags ittag.override -
close(
) → Future< void> -
override
-
createContainer(
ContainerSpec spec, Map< String, String> labels) → Future<String> -
Creates a container for
speccarryinglabels. Returns its id.override -
ensureNetwork(
String name, Map< String, String> labels) → Future<void> -
Creates a network named
namecarryinglabelsif none exists yet.override -
exec(
String id, List< String> command) → Future<ExecResult> -
Runs
commandinside the container and waits for it to finish.override -
getArchive(
String id, String path) → Future< Uint8List> -
Reads the file or directory at
pathout of the container, as a ustar archive — whatGET /containers/{id}/archivereturns.override -
imageExists(
String image) → Future< bool> -
override
-
inspectContainer(
String id) → Future< ContainerInspect> -
override
-
listContainers(
{Map< String, List< filters = const {}, bool all = true}) → Future<String> >List< ContainerSummary> > -
Containers matching
filters, in Docker's filter form:{'label': ['dev.dart-forge.rig=1'], 'status': ['running']}.override -
listNetworks(
{Map< String, List< filters = const {}}) → Future<String> >List< NetworkSummary> > -
Networks matching
filters, in the same form listContainers takes.override -
logs(
String id) → Future< String> -
The container's entire combined output, from the start.
override
-
logTail(
String id, {int lines = 50}) → Future< String> -
The last
lineslines of the container's combined output.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
ping(
) → Future< void> -
Throws DockerUnavailable when the daemon does not answer.
override
-
pullImage(
String image) → Future< void> -
Throws ImagePullFailed on failure.
override
-
putArchive(
String id, String path, List< int> tarBytes) → Future<void> -
Writes
tarBytes— a ustar archive — into the container, atpath.override -
queueHealth(
String id, List< HealthStatus> statuses) → void -
Makes inspectContainer report
statusesin order, then hold the last. -
removeContainer(
String id) → Future< void> -
override
-
removeImage(
String tag) → Future< void> -
Remove the image tagged
tag.override -
removeNetwork(
String id) → Future< bool> -
Removes the network
id.override -
setLogs(
String id, String logs) → void -
startContainer(
String id) → Future< void> -
override
-
stopContainer(
String id, {Duration timeout = const Duration(seconds: 2)}) → Future< void> -
override
-
toString(
) → String -
A string representation of this object.
inherited
-
version(
) → Future< EngineVersion> -
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited