ci_info::mock_ci - Rust
Description: API documentation for the Rust `mock_ci` fn in crate `ci_info`.
Keywords: rust, rustlang, rust-lang, mock_ci

# [−][src]Function ci_info::mock_ci

    pub fn mock_ci(info: &CiInfo)

This function will modify the current environment variables to mock the requested CI vendor.

# Example

    use ci_info::types::{CiInfo, Vendor};

    fn main() {
        // create the CI info manually
        let mut mock_info = CiInfo::new();
        mock_info.vendor = Some(Vendor::TravisCI);
        mock_info.ci = true;
        mock_info.pr = Some(true);
        mock_info.branch_name = Some("dev_branch".to_string());

        // mock environment
        ci_info::mock_ci(&mock_info);

        let info = ci_info::get();

        assert!(info.ci);
        assert!(info.pr.unwrap());
        assert_eq!(info.vendor.unwrap(), Vendor::TravisCI);
        assert_eq!(info.name.unwrap(), "Travis CI");
        assert_eq!(info.branch_name.unwrap(), "dev_branch");

        // clear CI environment
        mock_info = CiInfo::new();
        ci_info::mock_ci(&mock_info);

        let info = ci_info::get();

        assert!(!info.ci);
    }