Skip to main content

Module testing

Module testing 

Source
Expand description

Testing utilities for overriding option values in tests.

§Example

use sentry_options::Options;
use sentry_options::testing::override_options;
use serde_json::json;

#[test]
fn test_feature() {
    let opts = Options::from_directory(test_dir).unwrap();

    let _guard = override_options(&[("seer", "feature.enabled", json!(true))]).unwrap();
    assert_eq!(opts.get("seer", "feature.enabled").unwrap(), json!(true));
}

Structs§

OverrideGuard
Guard that restores overrides when dropped.

Functions§

clear_override
Clear an override for a specific namespace and key.
ensure_initialized
Initialize options, ignoring “already initialized” errors.
get_override
Get an override value if one exists.
override_options
Set overrides for the lifetime of the returned guard.
set_override
Set an override value for a specific namespace and key.