Google Cloud Emulators¶
Allows to spin up google cloud emulators, such as PubSub.
- class testcontainers.google.PubSubContainer(image='google/cloud-sdk:latest', project='test-project', port=8432, **kwargs)¶
PubSub container for testing managed message queues.
Example
The example will spin up a Google Cloud PubSub emulator that you can use for integration tests. The
pubsub
instance provides convenience methodsget_publisher
andget_subscriber
to connect to the emulator without having to set the environment variablePUBSUB_EMULATOR_HOST
.def test_docker_run_pubsub(): config = PubSubContainer('google/cloud-sdk:latest') with config as pubsub: publisher = pubsub.get_publisher() topic_path = publisher.topic_path(pubsub.project, "my-topic") topic = publisher.create_topic(topic_path)