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

Code before:
    fn testing_for_solcjs_render() -> io::Result<()> {
        let tempdir = tempfile::tempdir()?;
        // Create some file needed to render the module
        File::create(tempdir.path().join("main.sol"))?.sync_all()?;

        // The output of the module
        let actual = ModuleRenderer::new("solidity")
            // For a custom path
            .path(tempdir.path())
            // For a custom config
            .config(toml::toml! {
               [solidity]
               compiler = "solcjs"
            })
            // Run the module and collect the output
            .collect();

        // The value that should be rendered by the module.
        let expected = Some(format!("via {}", Color::Blue.bold().paint("S v0.8.15")));

        // Assert that the actual and expected values are the same
        assert_eq!(actual, expected);

        // Close the tempdir
        tempdir.close()
    }
}


Review comment (suggestion):
Might be good to test the fallback too.
```suggestion
    }
    #[test]
    fn testing_sol_fallback() -> io::Result<()> {
        let tempdir = tempfile::tempdir()?;
        // Create some file needed to render the module
        File::create(tempdir.path().join("main.sol"))?.sync_all()?;

        // The output of the module
        let actual = ModuleRenderer::new("solidity")
            // For a custom path
            .path(tempdir.path())
            // Make regular solc unavailable
            .cmd("solc --version", None)
            // Custom Config
            .config(toml::toml! {
              [solidity]
              compiler = ["solc", "solcjs"]
            ])
            // Run the module and collect the output
            .collect();

        // The value that should be rendered by the module.
        let expected = Some(format!("via {}", Color::Blue.bold().paint("S v0.8.15")));

        // Assert that the actual and expected values are the same
        assert_eq!(actual, expected);

        // Close the tempdir
        tempdir.close()
    }
```

Code after:
    fn testing_for_solcjs_render() -> io::Result<()> {
        let tempdir = tempfile::tempdir()?;
        // Create some file needed to render the module
        File::create(tempdir.path().join("main.sol"))?.sync_all()?;

        // The output of the module
        let actual = ModuleRenderer::new("solidity")
            // For a custom path
            .path(tempdir.path())
            // For a custom config
            .config(toml::toml! {
               [solidity]
               compiler = "solcjs"
            })
            // Run the module and collect the output
            .collect();

        // The value that should be rendered by the module.
        let expected = Some(format!("via {}", Color::Blue.bold().paint("S v0.8.15")));

        // Assert that the actual and expected values are the same
        assert_eq!(actual, expected);

        // Close the tempdir
        tempdir.close()
    }

    #[test]
    fn testing_sol_fallback() -> io::Result<()> {
        let tempdir = tempfile::tempdir()?;
        // Create some file needed to render the module
        File::create(tempdir.path().join("main.sol"))?.sync_all()?;
        // The output of the module
        let actual = ModuleRenderer::new("solidity")
            // For a custom path
            .path(tempdir.path())
            // Make regular solc unavailable
            .cmd("solc --version", None)
            // Custom Config
            .config(toml::toml! {
                      [solidity]
                      compiler = ["solc", "solcjs"]
            })
            // Run the module and collect the output
            .collect();
        // The value that should be rendered by the module.
        let expected = Some(format!("via {}", Color::Blue.bold().paint("S v0.8.15")));
        // Assert that the actual and expected values are the same
        assert_eq!(actual, expected);
        // Close the tempdir
        tempdir.close()