testcontainers_core 1.0.14 copy "testcontainers_core: ^1.0.14" to clipboard
testcontainers_core: ^1.0.14 copied to clipboard

Dart library for throwaway instances of anything that can run in a Docker container

testcontainers #

Core library for managing throwaway Docker containers in Dart tests.

Usage #

import 'package:testcontainers_core/testcontainers.dart';

void main() async {
  await DockerContainer.use(
    DockerContainer('nginx:alpine').withExposedPorts([80]),
    (container) async {
      final port = await container.getExposedPortAsync(80);
      print('nginx running on port $port');
    },
  );
}

Wait Strategies #

// Wait for a log message
container.waitingFor(LogMessageWaitStrategy('Server started'));

// Wait for an HTTP endpoint
container.waitingFor(HttpWaitStrategy(8080).forStatusCode(200));

// Wait for a TCP port
container.waitingFor(PortWaitStrategy(5432));

// Combine strategies
container.waitingFor(CompositeWaitStrategy([
  LogMessageWaitStrategy('ready'),
  PortWaitStrategy(5432),
]));

Network #

await Network.use((network) async {
  final a = DockerContainer('alpine').withNetwork(network);
  final b = DockerContainer('alpine').withNetwork(network);
  // a and b can communicate
});

License #

Apache 2.0

0
likes
155
points
67
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

Dart library for throwaway instances of anything that can run in a Docker container

Repository (GitHub)
View/report issues

Topics

#testing #docker #containers #test-automation

Funding

Consider supporting this project:

github.com

License

Apache-2.0 (license)

Dependencies

archive, http, meta, path, uuid

More

Packages that depend on testcontainers_core