Skip to content

How to pass different configuration to each test? #2856

Discussion options

You must be logged in to vote

Using Rocket::configure():

#[test]
fn test_simple() {
    let rocket = rocket().configure(provider);
    let client = Client::tracked(rocket);
}

provider here is any configuration source. If you want it to be a TOML file, then:

use rocket::figment::providers::{Toml, Format, Env};

let provider = Toml::file("some_file.toml").nested();

Maybe you just want to set one parameter, though. In which case, maybe you do something like:

use rocket::config::Config;

let provider = Config::figment()
    .merge(("databases.foo.url", "some_value"));    

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@szabgab
Comment options

Answer selected by szabgab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants