Code Monkey home page Code Monkey logo

dockertest-server's Introduction

dockertest-server

A test framework built around dockertest for testing against server containers.

This crate provides a small abstraction layer around the dockertest crate for easily running a test against multiple servers running in containers. It provides traits for defining a server and it's associated configuration and then registering a variable number of servers to bring up for a test.

The primary use-case of this crate is to provide an easy-to-use testing framework for crates that wish to build integration tests against services which are able to run in a container.

Installation

Add dockertest-server as a dependency to your cargo.toml:

[dev-dependencies]
dockertest-server = "0.1.7"

Usage

The below example brings up a mock OAuth server and then tests it's responding to HTTP requests:

// Note: This requires the `web` feature
use dockertest_server::servers::auth::{OIDCServer, OIDCServerConfig};
use dockertest_server::Test;

let config = OIDCServerConfig::builder().port(8090).build().unwrap();
let mut test = Test::new();
test.register(config);

test.run(|instance| async move {
    let server: OIDCServer = instance.server();

    let client = reqwest::Client::new();
    let resp = client
        .get(format!(
            "{}/default/.well-known/openid-configuration",
            server.external_url()
        ))
        .send()
        .await;
    assert!(resp.is_ok());
    assert_eq!(resp.unwrap().status(), 200);
});

This crate ships with support for various servers already included. See the servers module for the ones included. Note that most require a feature flag to be enabled to avoid bundling unnecessary implementations.

Please feel free to submit a PR with your own implementations to be added to the main crate.

Testing

Run tests with cargo test.

Contributing

Check out the issues for items needing attention or submit your own and then:

  1. Fork the repo (https://github.com/jmgilman/dockertest-server/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

dockertest-server's People

Contributors

jmgilman avatar anexen avatar kaplanelad avatar

Watchers

 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.