Repository: starship/starship
File: src/modules/package.rs (Rust)

Code before:
        let config_name = "Cargo.toml";
        let config_content = toml::toml! {
            [workspace.package]
            version = "0.1.0"
            [package]
            name = "starship"
            version.workspace = true
        }
        .to_string();

        let project_dir = create_project_dir()?;
        fill_config(&project_dir, config_name, Some(&config_content))?;
        expect_output(&project_dir, Some("v0.1.0"), None);
        project_dir.close()
    }

    #[test]
    fn test_extract_cargo_version_ws() -> io::Result<()> {
        let ws_config_name = "Cargo.toml";
        let ws_config_content = toml::toml! {
            [workspace.package]
            version = "0.1.0"

            [package]
            name = "root-crate"
            version.workspace = true
        }
        .to_string();

        let config_name = "member/Cargo.toml";
        let config_content = toml::toml! {
            [package]
            version.workspace = true
        }
        .to_string();

        let project_dir = create_project_dir()?;
        fs::create_dir(project_dir.path().join("member"))?;

        fill_config(&project_dir, ws_config_name, Some(&ws_config_content))?;
        fill_config(&project_dir, config_name, Some(&config_content))?;

        // Version can be read both from the workspace and the member.
        expect_output(&project_dir, Some("v0.1.0"), None);
        let actual = ModuleRenderer::new("package")
            .path(project_dir.path().join("member"))
            .collect();
        let expected = Some(format!(
            "is {} ",
            Color::Fixed(208).bold().paint("📦 v0.1.0")
        ));

Review comment (suggestion):
Please keep this test as-is to avoid testing two equivalent configs:
```suggestion
```

Code after:
        let config_name = "Cargo.toml";
        let config_content = toml::toml! {
            [workspace.package]
            version = "0.1.0"
            [package]
            name = "starship"
            version.workspace = true
        }
        .to_string();

        let project_dir = create_project_dir()?;
        fill_config(&project_dir, config_name, Some(&config_content))?;
        expect_output(&project_dir, Some("v0.1.0"), None);
        project_dir.close()
    }

    #[test]
    fn test_extract_cargo_version_ws() -> io::Result<()> {
        let ws_config_name = "Cargo.toml";
        let ws_config_content = toml::toml! {
            [workspace.package]
            version = "0.1.0"
        }
        .to_string();

        let config_name = "member/Cargo.toml";
        let config_content = toml::toml! {
            [package]
            version.workspace = true
        }
        .to_string();

        let project_dir = create_project_dir()?;
        fs::create_dir(project_dir.path().join("member"))?;

        fill_config(&project_dir, ws_config_name, Some(&ws_config_content))?;
        fill_config(&project_dir, config_name, Some(&config_content))?;

        // Version can be read both from the workspace and the member.
        expect_output(&project_dir, Some("v0.1.0"), None);
        let actual = ModuleRenderer::new("package")
            .path(project_dir.path().join("member"))
            .collect();
        let expected = Some(format!(
            "is {} ",
            Color::Fixed(208).bold().paint("📦 v0.1.0")
        ));
        assert_eq!(actual, expected);
        project_dir.close()
    }