Repository: starship/starship
File: src/test/mod.rs (Rust)

Code before:
        self
    }

    pub fn keymap<T>(mut self, keymap: T) -> Self
    where
        T: Into<String>,
    {
        self.context.properties.insert("keymap", keymap.into());
        self
    }

    pub fn status(mut self, status: i32) -> Self {
        self.context
            .properties
            .insert("status_code", status.to_string());
        self
    }

    /// Renders the module returning its output
    pub fn collect(self) -> Option<String> {
        let ret = crate::print::get_module(self.name, self.context);
        // all tests rely on the fact that an empty module produces None as output as the
        // convention was that there would be no module but None. This is nowadays not anymore
        // the case (to get durations for all modules). So here we make it so, that an empty
        // module returns None in the tests...
        match &ret {
            Some(value) => {
                if value == &String::from("") {
                    None
                } else {
                    ret
                }
            }
            None => None,
        }
    }
}

pub enum FixtureProvider {
    GIT,
    HG,
}

pub fn fixture_repo(provider: FixtureProvider) -> io::Result<TempDir> {
    match provider {
        FixtureProvider::GIT => {
            let path = tempfile::tempdir()?;

            Command::new("git")
                .current_dir(path.path())
                .args(&["clone", "-b", "master"])

Review comment (suggestion):
I'd prefer something like this:
```rust
match ret {
    Some("") => None,
    Some(_) => ret,
    None => None,
}
```

Code after:
        self
    }

    pub fn keymap<T>(mut self, keymap: T) -> Self
    where
        T: Into<String>,
    {
        self.context.properties.insert("keymap", keymap.into());
        self
    }

    pub fn status(mut self, status: i32) -> Self {
        self.context
            .properties
            .insert("status_code", status.to_string());
        self
    }

    /// Renders the module returning its output
    pub fn collect(self) -> Option<String> {
        let ret = crate::print::get_module(self.name, self.context);
        // all tests rely on the fact that an empty module produces None as output as the
        // convention was that there would be no module but None. This is nowadays not anymore
        // the case (to get durations for all modules). So here we make it so, that an empty
        // module returns None in the tests...
        ret.filter(|s| s != "")
    }
}

pub enum FixtureProvider {
    GIT,
    HG,
}

pub fn fixture_repo(provider: FixtureProvider) -> io::Result<TempDir> {
    match provider {
        FixtureProvider::GIT => {
            let path = tempfile::tempdir()?;

            Command::new("git")
                .current_dir(path.path())
                .args(&["clone", "-b", "master"])
                .arg(GIT_FIXTURE.as_os_str())
                .arg(&path.path())
                .output()?;

            Command::new("git")
                .args(&["config", "--local", "user.email", "starship@example.com"])
                .current_dir(&path.path())
                .output()?;