Coder Social home page Coder Social logo

neilyio / testcontainers-rs-modules-community Goto Github PK

View Code? Open in Web Editor NEW

This project forked from testcontainers/testcontainers-rs-modules-community

0.0 0.0 0.0 172 KB

Community maintained modules for Testcontainers for Rust

Home Page: https://docs.rs/crate/testcontainers-modules/

License: MIT License

Rust 100.00%

testcontainers-rs-modules-community's Introduction

testcontainers-modules

Continuous Integration Crates.io Docs.rs

Community maintained modules for testcontainers

Provides modules to use for testing components in accordance with testcontainers-rs. Every module is treated as a feature inside this crate.

Usage

  1. Depend on testcontainers-modules with necessary features (e.g postgres, minio and etc)
    • Enable blocking feature if you want to use modules within synchronous tests (feature-gate for SyncRunner)
  2. Then start using the modules inside your tests with either AsyncRunner or SyncRunner

Simple example of using postgres module with SyncRunner (blocking and posrges features enabled):

use testcontainers_modules::{postgres, testcontainers::runners::SyncRunner};

#[test]
fn test_with_postgres() {
    let container = postgres::Postgres::default().start();
    let host_ip = container.get_host();
    let host_port = container.get_host_port_ipv4(5432);
}

Note: you don't need to explicitly depend on testcontainers as it's re-exported dependency of testcontainers-modules with aligned version between these crates. For example:

use testcontainers_modules::testcontainers::RunnableImage;

You can also see examples for more details.

How to override module defaults (version, tag, ENV-variables)

Just use RunnableImage:

use testcontainers_modules::{
    redis::Redis,
    testcontainers::RunnableImage
};


/// Create a Redis module with `6.2-alpine` tag and custom password
fn create_redis() -> RunnableImage<Redis> {
    RunnableImage::from(Redis::default())
        .with_tag("6.2-alpine")
        .with_env_var(("REDIS_PASSWORD", "my_secret_password"))
}

License

testcontainers-rs-modules-community's People

Contributors

dependabot[bot] avatar ddtkey avatar github-actions[bot] avatar mervyn-mccreight avatar tsurai avatar brianheineman avatar dlen avatar flobz avatar bakrog avatar haboumrad avatar jasondemorrow avatar jarsop avatar kiview avatar kymmt90 avatar knutwalker avatar ruslansennov avatar esposm03 avatar ubiratansoares avatar buildwithzephyr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.